Part Number Hot Search : 
1N3701B MSB054 CUS15S40 AO460409 LCX16 05E41 PCA9501D DCPC1460
Product Description
Full Text Search
 

To Download AT91SAM9G45PRE Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  features ? 400 mhz arm926ej-s? arm ? thumb ? processor ? 32 kbytes data cache, 32 kbytes instruction cache, mmu ? memories ? ddr2 controller 4-bank ddr2/lpddr, sdram/lpsdr ? external bus interface sup porting 4-bank ddr2/lpddr, sdram/lpsdr, static memories, compactflash, slc nand flash with ecc ? one 64-kbyte internal sram , single-cycle access at system speed or processor speed through tcm interface ? one 64-kbyte internal rom, embedding bootstrap routine ? peripherals ? lcd controller supporting stn and tft displays up to 1280*860 ? itu-r bt. 601/656 image sensor interface ? usb device high speed, us b host high speed and usb ho st full speed with on- chip transceiver ? 10/100 mbps ethern et mac controller ? two high speed memory card hosts (sdio, sdcard, mmc) ? ac'97 controller ? two master/slave serial peripheral interfaces ? two three-channel 16-bit timer/counters ? two synchronous serial controllers (i2s mode) ? four-channel 16-bit pwm controller ? two two-wire interfaces ? four usarts with iso7816, irda, manchester and spi modes ? 8-channel 10-bit adc with 4-wire touch screen support ? system ? 133 mhz twelve 32-bit layer ahb bus matrix ? 37 dma channels ? boot from nand flash, sdcard, dataflash? or serial dataflash ? reset controller with on-chip power-on reset ? selectable 32768 hz low-power and 12 mhz crystal oscillators ? internal low-power 32 khz rc oscillator ? one pll for the system and one 480 mhz pll optimized for usb high speed ? two programmable exte rnal clock signals ? advanced interrupt controller and debug unit ? periodic interval timer, watchdog timer, real time timer and real time clock ? i/o ? five 32-bit parallel input/output controllers ? 160 programmable i/o lines multiplexed with up to two peripheral i/os with schmitt trigger input ? package ? 324-ball tfbga, pitch 0.8 mm at91 arm thumb-based microcontrollers at91sam9g45 preliminary 6438fCatarmC21-jun-10
2 6438fCatarmC21-jun-10 at91sam9g45 1. description the arm926ej-s based at91sam9g45 features the frequently demanded combination of user interface functionality and high data rate connecti vity, including lcd controller, resistive touch- screen, camera interface, audio, ethernet 10/100 and high speed usb and sdio. with the pro- cessor running at 400mhz and multiple 100+ m bps data rate peripherals, the at91sam9g45 has the performance and bandwidth to the network or local storage media to provide an ade- quate user experience. the at91sam9g45 supports the latest generation of ddr2 and nand flash memory inter- faces for program and data storage. an internal 133 mhz multi-layer bus architecture associated with 37 dma channels, a dual external bus interface and distributed memory including a 64- kbyte sram which can be configured as a tightly coupled memory (tcm) sustains the high bandwidth required by the processor and the high speed peripherals. the i/os support 1.8v or 3.3v operation, which are independently configurable for the memory interface and peripheral i/os. this feature completely eliminates the need for any external level shifters. in addition it supports 0.8 ball pitch package for low cost pcb manufacturing. the at91sam9g45 power management controller features efficient clock gating and a battery backup section minimizing power cons umption in active and standby modes.
3 6438fCatarmC21-jun-10 at91sam9g45 2. block diagram figure 2-1. at91sam9g45 block diagram aic apb plla system controller pmc pllutmi pit wdt rtt osc 32k shdc rstc por dbgu pdc 4 gpbr static memory controller cf twi0 twi1 usart0 usart1 usart2 usart3 pdc pdc 4-ch pwm tc0 tc1 tc2 peripheral dma controller peripheral bridge rom 64kb osc12m pdc piob multi-layer ahb matrix por pioc rtc rc piod hs transceiver hs transceiver ddr2 lpddr 8-ch 10bit adc touchscreen ac97 pdc pdc ssc0 ssc1 pio pio pio nand flash controller ecc arm926ej-s jtag / boundary scan in-circuit emulator mmu bus interface id icache 32 kbytes dcache 32 kbytes pioe pioa ddr2/ lpddr/ sdram controller fifo dtcm sram 64kb itcm ddr_d0-ddr_d15 ddr_a0-ddr_a13 ddr_cs ddr_cke ddr_ras, ddr_cas ddr_clk,#ddr_clk ddr_dqs[0..1] ddr_dqm[0..1] ddr_vref ddr_we ddr_ba0, ddr_ba1 d0-d15 a0/nbs0 a2-a15, a18 a16/ba0 a17/ba1 ncs0 ncs1/sdcs nrd nwr0/nwe nwr1/nbs1 nwr3/nbs3 sdck, #sdck, sdcke ras, cas sdwe, sda10 a1/nbs2/nwr2 nandoe, nandwe a19-a24 ncs5/cfcs1 a25/cfrnw ncs4/cfcs0 nwait cfce1-cfce2 ncs2 ncs3/nandcs d16-d31 npcs2 npcs1 spck mosi miso npcs0 npcs3 ac97ck ac97fs ac97rx ac97tx tsadtrig gpad4-gpad7 ad0xp ad1xm ad2yp gndan vddana tsadvref ad3ym tk0-tk1 tf0-tf1 td0-td1 rd0-rd1 rf0-rf1 rk0-rk1 tclk0-tclk2 tioa0-tioa2 tiob0-tiob2 pwm0-pwm3 spi0_, spi1_ ssc0_, ssc1_ rts0-rts3 sck0-sck3 txd0-txd3 rdx0-rdx3 cts0-cts3 twck0-twck1 twd0-twd1 mci0_ck,mci1_ck mci0_da0-mci0_da7 mci0_cda,mci1_cda isi_pck isi_do-isi_d11 isi_hsync lcdd0-lcdd23 lcdvsync,lcdhsync lcddotck ldden,lcdcc lcdpwr, lcdmod vbg isi_vsync isi_mck dfsdp/hfsdpb,dfsdm/hfsdmb dhsdp/hhsdpb,dhsdm/hhsdmb hfsdpa,hfsdma hhsdpa,hhsdma etxck-erxck etxen-etxer ecrs-ecol erxer-erxdv erx0-erx3 etx0-etx3 emdc emdio tdi ntrst tdo tms tck jtagsel rtck bms lcd dma dma dma dma isi dma emac 8-ch dma fiq irq drxd dtxd pck0-pck1 vddbu shdn wkup xin nrst xout xin32 xout32 vddcore tst dqm[0..1] dqs[0..1] trng dqm[2..3] mci1_da0-mci1_da7 tc3 tc4 tc5 tclk3-tclk5 tioa3-tioa5 tiob3-tiob5 ebi spi0 spi1 hs ehci usb host pa p b hs usb mci0/mci1 sd/sdio ce ata
4 6438fCatarmC21-jun-10 at91sam9g45 3. signal description table 3-1 gives details on the signal names classified by peripheral. table 3-1. signal description list signal name function type active level reference voltage comments power supplies vddiom0 ddr2 i/o lines power supply power 1.65v to 1.95v vddiom1 ebi i/o lines power supply po wer 1.65v to 1.95v or 3.0v to3.6v vddiop0 peripherals i/o lines power supply power 1.65v to 3.6v vddiop1 peripherals i/o lines power supply power 1.65v to 3.6v vddiop2 isi i/o lines power supply power 1.65v to 3.6v vddbu backup i/o lines power supply power 1.8v to 3.6v vddana analog power supply power 3.0v to 3.6v vddplla plla power supply power 0.9v to 1.1v vddpllutmi pllutmi power supply power 0.9v to 1.1v vddosc oscillator power supply power 1.65v to 3.6v vddcore core chip power supply power 0.9v to 1.1v vddutmic udphs and uhphs utmi+ core power supply power 0.9v to 1.1v vddutmii udphs and uhphs utmi+ interface power supply power 3.0v to 3.6v gndiom ddr2 and ebi i/o lines ground ground gndiop peripherals and isi i/o lines ground ground gndcore core chip ground ground gndosc plla, pllutmi and oscillator ground ground gndbu backup ground ground gndutmi udphs and uhphs utmi+ core and interface ground ground gndana analog ground ground clocks, oscillators and plls xin main oscillator input input xout main oscillator output output xin32 slow clock oscillator input input xout32 slow clock oscillator output output vbg bias voltage reference for usb analog pck0 - pck1 programmabl e clock output output (1)
5 6438fCatarmC21-jun-10 at91sam9g45 shutdown, wakeup logic shdn shut-down control output vddbu driven at 0v only. 0: the device is in backup mode 1: the device is running (not in backup mode). wkup wake-up input input vddbu accept between 0v and vddbu. ice and jtag tck test clock input vddiop0 no pull-up resistor, schmitt trigger tdi test data in input vddiop0 no pull-up resistor, schmitt trigger tdo test data out output vddiop0 tms test mode select input vddiop0 no pull-up resistor, schmitt trigger jtagsel jtag selection input vddbu pull-down resistor (15 k ). rtck return test clock output vddiop0 reset/test nrst microcontroller reset (2) i/o low vddiop0 pull-up resistor (100 k ), schmitt trigger tst test mode select input vddbu pull-down resistor (15 k ), schmitt trigger ntrst test reset signal input vddiop0 pull-up resistor (100 k ), schmitt trigger bms boot mode select input vddiop0 must be connected to gnd or vddiop0. debug unit - dbgu drxd debug receive data input (1) dtxd debug transmit data output (1) advanced interrupt controller - aic irq external interrupt input input (1) fiq fast interrupt input input (1) pio controller - pioa- piob - pioc - piod - pioe pa0 - pa31 parallel io controller a i/o (1) pulled-up input at reset (100k ) (3) , schmitt trigger pb0 - pb31 parallel io controller b i/o (1) pulled-up input at reset (100k ) (3) , schmitt trigger pc0 - pc31 parallel io controller c i/o (1) pulled-up input at reset (100k ) (3) , schmitt trigger table 3-1. signal description list (continued) signal name function type active level reference voltage comments
6 6438fCatarmC21-jun-10 at91sam9g45 pd0 - pd31 parallel io controller d i/o (1) pulled-up input at reset (100k ) (3) , schmitt trigger pe0 - pe31 parallel io controller e i/o (1) pulled-up input at reset (100k ) (3) , schmitt trigger ddr memory interface- dd r2/sdram/lpddr controller ddr_d0 - ddr_d15 data bus i/o vddiom0 pulled-up input at reset ddr_a0 - ddr_a13 address bus output vddiom0 0 at reset ddr_clk- #ddr_clk ddr differential clock input output vddiom0 ddr_cke ddr clock enable output high vddiom0 ddr_cs ddr chip select output low vddiom0 ddr_we ddr write enable output low vddiom0 ddr_ras- ddr_cas row and column signal output low vddiom0 ddr_dqm[0..1] write data mask output vddiom0 ddr_dqs[0..1] data st robe output vddiom0 ddr_ba0 - ddr_ba1 bank select output vddiom0 ddr_vref reference voltage input vddiom0 external bus interface - ebi d0 -d31 data bus i/o vddiom1 pulled-up input at reset a0 - a25 address bus output vddiom1 0 at reset nwait external wait signal input low vddiom1 static memory controller - smc ncs0 - ncs5 chip select lines output low vddiom1 nwr0 - nwr3 write signal output low vddiom1 nrd read signal output low vddiom1 nwe write enable output low vddiom1 nbs0 - nbs3 byte mask signal output low vddiom1 compactflash support cfce1 - cfce2 compactflash ch ip enable output low vddiom1 cfoe compactflash output enable output low vddiom1 cfwe compactflash write enable output low vddiom1 cfior compactflash io read output low vddiom1 cfiow compactflash io write output low vddiom1 cfrnw compactflash read not write output vddiom1 table 3-1. signal description list (continued) signal name function type active level reference voltage comments
7 6438fCatarmC21-jun-10 at91sam9g45 cfcs0 -cfcs1 compactflash chip select lines output low vddiom1 nand flash support nandcs nand flash chip select output low vddiom1 nandoe nand flash output enable output low vddiom1 nandwe nand flash write enable output low vddiom1 ddr2/sdram/lpddr controller sdck,#sdck ddr2/sdram differential clock output vddiom1 sdcke ddr2/sdram clock enable output high vddiom1 sdcs ddr2/sdram controller chip select output low vddiom1 ba0 - ba1 bank select output vddiom1 sdwe ddr2/sdram write enable output low vddiom1 ras - cas row and column signal output low vddiom1 sda10 sdram address 10 line output vddiom1 dqs[0..1] data strobe output vddiom1 dqm[0..3] write data mask output vddiom1 high speed multimedia card interface - hsmcix mcix_ck multimedia card clock i/o (1) mcix_cda multimedia card slot a command i/o (1) mcix_da0 - mcix_da7 multimedia card slot a data i/o (1) universal synchronous asynchronous receiver transmitter - usartx sckx usartx serial clock i/o (1) txdx usartx transmit data output (1) rxdx usartx receive data input (1) rtsx usartx request to send output (1) ctsx usartx clear to send input (1) synchronous serial controller - sscx tdx ssc transmit data output (1) rdx ssc receive data input (1) tkx ssc transmit clock i/o (1) rkx ssc receive clock i/o (1) tfx ssc transmit frame sync i/o (1) rfx ssc receive frame sync i/o (1) table 3-1. signal description list (continued) signal name function type active level reference voltage comments
8 6438fCatarmC21-jun-10 at91sam9g45 ac97 controller - ac97c ac97rx ac97 receive signal input (1) ac97tx ac97 transmit signal output (1) ac97fs ac97 frame synchronization signal output (1) ac97ck ac97 clock signal input (1) time counter - tcx tclkx tc channel x external clock input input (1) tioax tc channel x i/o line a i/o (1) tiobx tc channel x i/o line b i/o (1) pulse width modulation controller - pwm pwmx pulse width modulation output output (1) serial peripheral interface - spix_ spix_miso master in slave out i/o (1) spix_mosi master out slave in i/o (1) spix_spck spi serial clock i/o (1) spix_npcs0 spi peripheral chip select 0 i/o low (1) spix_npcs1- spix_npcs3 spi peripheral chip select output low (1) two-wire interface twdx two-wire serial data i/o (1) twckx two-wire serial clock i/o (1) usb host high speed port - uhphs hfsdpa usb host port a full speed data + analog vddutmii hfsdma usb host port a full speed data - analog vddutmii hhsdpa usb host port a high speed data + analog vddutmii hhsdma usb host port a high speed data - analog vddutmii hfsdpb usb host port b full speed data + analog vddutmii multiplexed with dfsdp hfsdmb usb host port b full speed data - analog vddutmii multiplexed with dfsdm hhsdpb usb host port b high speed data + analog vddutmii multiplexed with dhsdp hhsdmb usb host port b high speed data - analog vddutmii multiplexed with dhsdm usb device high speed port - udphs dfsdm usb device full speed data - analog vddutmii dfsdp usb device full speed data + analog vddutmii dhsdm usb device high speed data - analog vddutmii dhsdp usb device high speed data + analog vddutmii table 3-1. signal description list (continued) signal name function type active level reference voltage comments
9 6438fCatarmC21-jun-10 at91sam9g45 ethernet 10/100 etxck transmit clock or reference clock input (1) mii only, refck in rmii erxck receive clock input (1) mii only etxen transmit enable output (1) etx0-etx3 transmit data output (1) etx0-etx1 only in rmii etxer transmit coding error output (1) mii only erxdv receive data valid input (1) rxdv in mii, crsdv in rmii erx0-erx3 receive data input (1) erx0-erx1 only in rmii erxer receive error input (1) ecrs carrier sense and data valid input (1) mii only ecol collision detect input (1) mii only emdc management data clock output (1) emdio management data input/output i/o (1) image sensor interface isi_d0-isi_d11 image sensor data input vddiop2 isi_mck image sensor reference clock output vddiop2 isi_hsync image sensor horizontal synchro input vddiop2 isi_vsync image sensor vertical synchro input vddiop2 isi_pck image sensor data clock input vddiop2 lcd controller - lcdc lcdd0 - lcdd23 lcd data bus output vddiop1 lcdvsync lcd vertical sync hronization output vddiop1 lcdhsync lcd horizontal synchronization output vddiop1 lcddotck lcd dot clock output vddiop1 lcdden lcd data enable output vddiop1 lcdcc lcd contrast control output vddiop1 lcdpwr lcd panel power enable control output vddiop1 lcdmod lcd modulation signal output vddiop1 touch screen analog-to-digital converter ad0x p analog input channel 0 or touch screen top channel analog vddana multiplexed with ad0 ad1x m analog input channel 1 or touch screen bottom channel analog vddana multiplexed with ad1 ad2y p analog input channel 2 or touch screen right channel analog vddana multiplexed with ad2 table 3-1. signal description list (continued) signal name function type active level reference voltage comments
10 6438fCatarmC21-jun-10 at91sam9g45 notes: 1. refer to peripheral multiplexing tables in section 8.4 peripheral signals multiplexing on i/o lines for these signals. 2. when configured as an input, the nrst pin enables asynchronous reset of the device when asserted low. this allows con- nection of a simple push button on the nrst pin as a system-user reset. 3. programming of this pull-up resistor is performed independently for each i/o line through the pio controllers. after reset, a ll the i/o lines default as inputs with pull-up re sistors enabled, except those which are multiplexed with the external bus inter- face signals that require to be enabled as peripheral at reset. th is is explicitly indicated in the column reset state of the peripheral multiplexing tables. ad3y m analog input channel 3 or touch screen left channel analog vddana multiplexed with ad3 gpad4-gpad7 analog inputs analog vddana tsadtrg adc trigger input vddana tsadvref adc reference analog vddana table 3-1. signal description list (continued) signal name function type active level reference voltage comments
11 6438fCatarmC21-jun-10 at91sam9g45 4. package and pinout the at91sam9g45 is delivered in a 324-ball tfbga package. 4.1 mechanical overview of t he 324-ball tfbga package figure 4-1 shows the orientation of the 324-ball tfbga package figure 4-1. orientation of the 324-ball tfbga package 1 3 4 5 6 7 8 9 101112131415 1617 218 a b c d e f g h j k l m n p r t u v bottom view
12 6438fCatarmC21-jun-10 at91sam9g45 4.2 324-ball tfbga package pinout table 4-1. at91sam9g45 pinout for 324-ball bga package pin signal name pin signal name pin signal name pin signal name a1 pc27 e10 nandwe k1 pe21 p10 tms a2 pc28 e11 dqs1 k2 pe23 p11 vddplla a3 pc25 e12 d13 k3 pe26 p12 pb20 a4 pc20 e13 d11 k4 pe22 p13 pb31 a5 pc12 e14 a4 k5 pe24 p14 ddr_d7 a6 pc7 e15 a8 k6 pe25 p15 ddr_d3 a7 pc5 e16 a9 k7 pe27 p16 ddr_d4 a8 pc0 e17 a7 k8 pe28 p17 ddr_d5 a9 nwr3/nbs3 e18 vddcore k9 vddiop0 p18 ddr_d10 a10 ncs0 f1 pd22 k10 vddiop0 r1 pa18 a11 dqs0 f2 pd24 k11 gndiom r2 pa20 a12 ras f3 shdn k12 gndiom r3 pa24 a13 sdck f4 pe1 k13 vddiom0 r4 pa30 a14 nsdck f5 pe3 k14 ddr_a7 r5 pb4 a15 d7 f6 vddiom1 k15 ddr_a8 r6 pb13 a16 ddr_vref f7 pc19 k16 ddr_a9 r7 pd0 a17 d0 f8 pc14 k17 ddr_a11 r8 pd9 a18 a14 f9 pc4 k18 ddr_a10 r9 pd18 b1 pc31 f10 ncs1/sdcs l1 pa0 r10 tdi b2 pc29 f11 nrd l2 pe30 r11 rtck b3 pc30 f12 sdwe l3 pe29 r12 pb22 b4 pc22 f13 a0/nbs0 l4 pe31 r13 pb29 b5 pc17 f14 a1/nbs2/nwr2 l5 pa2 r14 ddr_d6 b6 pc10 f15 a3 l6 pa4 r15 ddr_d1 b7 pc11 f16 a6 l7 pa8 r16 ddr_d0 b8 pc2 f17 a5 l8 pd2 r17 hhsdma b9 sda10 f18 a2 l9 pd13 r18 hfsdma b10 a17/ba1 g1 pd25 l10 pd29 t1 pa22 b11 dqm0 g2 pd23 l11 pd31 t2 pa25 b12 sdcke g3 pe6 l12 vddiom0 t3 pa26 b13 d12 g4 pe0 l13 vddiom0 t4 pb0 b14 d8 g5 pe2 l14 ddr_a1 t5 pb6 b15 d4 g6 pe8 l15 ddr_a3 t6 pb16 b16 d3 g7 pe4 l16 ddr_a4 t7 pd1 b17 a15 g8 pe11 l17 ddr_a6 t8 pd11 b18 a13 g9 gndcore l18 ddr_a5 t9 pd19 c1 xin32 g10 vddiom1 m1 pa1 t10 pd30 c2 gndana g11 vddiom1 m2 pa5 t11 bms c3 wkup g12 vddcore m3 pa6 t12 pb8 c4 pc26 g13 vddcore m4 pa7 t13 pb30 c5 pc21 g14 ddr_dqm0 m5 pa10 t14 ddr_d2 c6 pc15 g15 ddr_dqs1 m6 pa14 t15 pb21 c7 pc9 g16 ddr_ba1 m7 pb14 t16 pb23 c8 pc3 g17 ddr_ba0 m8 pd4 t17 hhsdpa c9 nwr0/nwe g18 ddr_dqs0 m9 pd15 t18 hfsdpa c10 a16/ba0 h1 pd26 m10 nrst u1 pa27 c11 cas h2 pd27 m11 pb11 u2 pa29 c12 d15 h3 vddiop1 m12 pb25 u3 pa28
13 6438fCatarmC21-jun-10 at91sam9g45 c13 d10 h4 pe13 m13 pb27 u4 pb3 c14 d6 h5 pe5 m14 vddiom0 u5 pb7 c15 d2 h6 pe7 m15 ddr_d14 u6 pb17 c16 gndiom h7 pe9 m16 ddr_d15 u7 pd7 c17 a18 h8 pe10 m17 ddr_a0 u8 pd10 c18 a12 h9 gndcore m18 ddr_a2 u9 pd14 d1 xout32 h10 gndiop n1 pa3 u10 tck d2 pd20 h11 vddcore n2 pa9 u11 vddosc d3 gndbu h12 gndiom n3 pa12 u12 gndosc d4 vddbu h13 gndiom n4 pa15 u13 pb10 d5 pc24 h14 ddr_cs n5 pa16 u14 pb26 d6 pc18 h15 ddr_we n6 pa17 u15 hhsdpb/dhsdp d7 pc13 h16 ddr_dqm1 n7 pb18 u16 hhsdmb/dhsdm d8 pc6 h17 ddr_cas n8 pd6 u17 gndutmi d9 nwr1/nbs1 h18 ddr_nclk n9 pd16 u18 vddutmic d10 nandoe j1 pe19 n10 ntrst v1 pa31 d11 dqm1 j2 pe16 n11 pb9 v2 pb1 d12 d14 j3 pe14 n12 pb24 v3 pb2 d13 d9 j4 pe15 n13 pb28 v4 pb5 d14 d5 j5 pe12 n14 ddr_d13 v5 pb15 d15 d1 j6 pe17 n15 ddr_d8 v6 pd3 d16 vddiom1 j7 pe18 n16 ddr_d9 v7 pd5 d17 a11 j8 pe20 n17 ddr_d11 v8 pd12 d18 a10 j9 gndcore n18 ddr_d12 v9 pd17 e1 pd21 j10 gndcore p1 pa11 v10 tdo e2 tsadvref j11 gndiop p2 pa13 v11 xout e3 vddana j12 gndiom p3 pa19 v12 xin e4 jtagsel j13 gndiom p4 pa21 v13 vddpllutmi e5 tst j14 ddr_a12 p5 pa23 v14 vddiop2 e6 pc23 j15 ddr_a13 p6 pb12 v15 hfsdpb/dfsdp e7 pc16 j16 ddr_cke p7 pb19 v16 hfsdmb/dfsdm e8 pc8 j17 ddr_ras p8 pd8 v17 vddutmii e9 pc1 j18 ddr_clk p9 pd28 v18 vbg table 4-1. at91sam9g45 pinout for 324-ball bga package (continued) pin signal name pin signal name pin signal name pin signal name
14 6438fCatarmC21-jun-10 at91sam9g45 5. power considerations 5.1 power supplies the at91sam9g45 has several types of power supply pins: ? vddcore pins: power the core, including the processor, the embedded memories and the peripherals; voltage ranges from 0.9v to 1.1v, 1.0v typical. ? vddiom0 pins: power the ddr2/lpddr i/o lines; voltage ranges between 1.65v and 1.95v (1.8v typical). ? vddiom1 pins: power the external bus interface 1 i/o lines; voltage ranges between 1.65v and 1.95v (1.8v typical) or between 3.0v and 3.6v (3.3v typical). ? vddiop0, vddiop1, vddiop2 pins: power the peripherals i/o lines; voltage ranges from 1.65v to 3.6v. ? vddbu pin: powers the slow clock oscillator, the internal rc oscilla tor and a part of the system controller; voltage ranges from 1.8v to 3.6v. ? vddpllutmi powers the pllutmi cell; voltage range from 0.9v to 1.1v. ? vddutmic pin: powers the usb device and host utmi+ core; voltage range from 0.9v to 1.1v, 1.0v typical. ? vddutmii pin: powers the usb device and host utmi+ interface; voltage range from 3.0v to 3.6v, 3.3v typical. ? vddplla pin: powers the plla cell; voltage ranges from 0.9v to 1.1v. ? vddosc pin: powers the main oscillator ce lls; voltage ranges from 1.65v to 3.6v ? vddana pin: powers the analog to digital converter; voltage ranges from 3.0v to 3.6v, 3.3v typical. ground pins gnd are common to vddiom0, v ddiom1, vddiop0, vddiop1 and vddiop2 power supplies. separated ground pins are provided for vddutmic , vddutmii, vddbu, vddosc, vddplla, vddpllutmi and vddana . these ground pins are respectively gndutmic, gndutmii, gndbu, gndosc , gndplla, gndpllutmi and gndana.
15 6438fCatarmC21-jun-10 at91sam9g45 6. memories figure 6-1. at91sam9g45 memory mapping addre ss memory s p a ce intern a l memorie s 0x00000000 ebi chip s elect 0 0x10000000 ebi chip s elect 1 ddr s drc1 0x20000000 ebi chip s elect 2 0x30000000 ebi chip s elect 3 nandfl as h 0x40000000 ebi chip s elect 4 comp a ct fl as h s lot 0 0x50000000 ebi chip s elect 5 comp a ct fl as h s lot 1 0x60000000 ddr s drc0 chip s elect 0x70000000 undefined (a b ort) 0x80000000 intern a l peripher a l s 0xf0000000 0xffffffff intern a l memorie s boot memory 0x00000000 itcm 0x00100000 dtcm 0x00200000 s ram 0x00300000 rom 0x00400000 lcdc 23 0x00500000 udph s (dma) 0x00600000 uhp ohci 0x00700000 uhp ehci 0x00800000 re s erved 0x00900000 undefined (a b ort) 0x00a00000 0x0fffffff intern a l peripher a l s re s erved 0xf0000000 udph s 27 0xfff78000 tc0 tc0 0xfff7c000 +18 tc0 tc1 +0x40 +18 tc0 tc2 +0x80 h s mci0 11 0xfff80000 twi0 12 0xfff84000 twi1 13 0xfff88000 u s art0 7 0xfff8c000 u s art1 8 0xfff90000 u s art2 9 0xfff94000 u s art 3 10 0xfff98000 ss c0 16 0xfff9c000 ss c1 17 0xfffa0000 s pi0 14 0xfffa4000 s pi1 15 0xfffa8000 ac97c 24 0xfffac000 t s adcc 20 0xfffb0000 i s i 26 0xfffb4000 pwm 19 0xfffb8000 emac 25 0xfffbc000 re s erved 0xfffc0000 re s erved 0xfffc4000 re s erved 0xfffc8000 trng 6 0xfffcc000 h s mci1 29 0xfffd0000 tc1 tc 3 0xfffd4000 tc1 tc4 +0x40 tc1 tc5 +0x80 re s erved 0xfffd8000 s y s tem controller 0xffffc000 0xffffffff s y s tem controller re s erved 0xffff0000 ddr s drc1 0xffffe400 ddr s drc0 0xffffe600 s mc 0xffffe800 matrix 0xffffea00 dmac 21 0xffffec00 dbgu 0xffffee00 aic 0;31 0xfffff000 pioa 2 0xfffff200 piob 3 0xfffff400 pioc 4 0xfffff600 piod +5 0xfffff800 pioe +5 0xfffffa00 pmc 0xfffffc00 sysc r s tc 0xfffffd00 1 sysc s hdwc +0x10 1 sysc rtt +0x20 1 sysc pit +0x30 1 sysc wdt +0x40 1 sysc s ckcr +0x50 1 sysc gpbr +0x60 1 sysc re s erved +0x70 rtc 0xfffffdb0 re s erved 0xfffffdc0 0xffffffff offset id (+ : wired-or) peripher a l block ecc 0xffffe200
16 6438fCatarmC21-jun-10 at91sam9g45 6.1 memory mapping a first level of address decoding is performed by the ahb bus matrix, i.e., the implementation of the advanced high performance bus (ahb) for its ma ster and slave interfaces with additional features. decoding breaks up the 4 gbytes of address spac e into 16 banks of 256 mbytes. the banks 1 to 6 are directed to the ebi that associates these banks to the external chip selects ncs0 to ncs5. the bank 7 is directed to the ddrsdrc0 that associates this bank to ddr_ncs chip select and so dedicated to the 4-port ddr2/ lpddr controller. the bank 0 is reserved for the addressing of the internal memories, and a second level of decoding provides 1 mbyte of internal memory area. the bank 15 is reserved for the peripherals and provides access to the ad vanced peripheral bus (apb). other areas are unused and performing an access within them provides an abort to the master requesting such an access. 6.2 embedded memories 6.2.1 internal sram the at91sam9g45 product embeds a total of 64kbytes high- speed sram split in 4 blocks of 16 kbytes connected to one slave of the matrix . after reset and until the remap command is performed, the four sram blocks are contiguous and only accessible at address 0x00300000. after remap, the sram also becomes available at address 0x0. figure 6-2. internal sram reset the at91sam9g45 device embeds two memory features. the processor tightly coupled mem- ory interface (tcm) that allows the processo r to access the memory up to processor speed (pck) and the interface on the ahb side allowing masters to access the memory at ahb speed (mck). a wait state is necessary to access the tcm at 400 mhz. setting the bit nws_tcm in the bus matrix tcm configuration register of the matrix inserts a wait state on the itcm and dtcm accesses. ram 64k 0x00300000 ram 64k 0x00000000 remap
17 6438fCatarmC21-jun-10 at91sam9g45 6.2.2 tcm interface on the processor side, this internal sram can be allocated to two areas. ? internal sram a is the arm926ej-s instruction tcm. the user can map this sram block anywhere in the arm926 instruction memory space using cp15 instructions and the tcr configuration register located in the chip conf iguration user interface. this sram block is also accessible by the arm926 masters and by the ahb masters through the ahb bus ? internal sram b is the arm926ej-s data tcm. the user can map this sram block anywhere in the arm926 data memory space using cp15 instructions. this sram block is also accessible by the arm926 data master and by the ahb masters through the ahb bus. ? internal sram c is only accessible by all th e ahb masters. after reset and until the remap command is performed, this sram block is accessible through the ahb bus at address 0x0030 0000 by all the ahb masters. after remap, this sram block also becomes accessible through the ahb bus at address 0x0 by the arm926 instruction and the arm926 data masters. within the 64kbyte sram size available, the amou nt of memory assigned to each block is soft- ware programmable according to table 6-1 . 6.2.3 internal rom the at91sam9g45 embeds an internal rom, which contains the boot rom and sam-ba ? program. at any time, the rom is mapped at address 0x0040 0000. it is also accessible at address 0x0 (bms =1) after the reset and before the remap command. 6.3 i/o drive selection and delay control 6.3.1 i/o drive selection the aim of this control is to adapt the signal drive to the frequency. two bits allow the user to select high or low drive for memories data/address/ctrl signals. ? setting the bit [17], ebi_drive, in the ebi_csa register of the matrix allows to control the drive of the ebi. ? setting the bit [18], ddr_drive, in the ebi_csa re gister of the matrix allows to control the drive of the ddr. 6.3.2 delay control to avoid the simultaneous switching of all the i/os, a delay can be inserted on the different ebi, ddr2 and pio lines. table 6-1. itcm and dtcm memory configuration sram a itcm size (kbytes) seen at 0x100000 through ahb sram b dtcm size (kbytes) seen at 0x200000 through ahb sram c (kbytes) seen at 0x300000 through ahb 0064 064 0 32 32 0
18 6438fCatarmC21-jun-10 at91sam9g45 the control of these delays is the following: ? ddrsdrc ddr_d[15:0] controlled by 2 registers, delay1 a nd delay2, located in the ddrsdrc user interface C ddr_d[0] <=> delay1[3:0], C ddr_d[1] <=> delay1[7:4],... C ddr_d[6] <=> delay1[27:24], C ddr_d[7] <=> delay1[31:28] C ddr_d[8] <=> delay2[3:0], C ddr_d[9] <=> delay2[7:4],..., C ddr_d[14] <=> delay2[27:24], C ddr_d[15] <=> delay2[31:28] ddr_a[13:0] controlled by 2 registers, delay3 a nd delay4, located in the ddrsdrc user interface C ddr_a[0] <=> delay3[3:0], C ddr_a[1] <=> delay3[7:4], ..., C ddr_a[6] <=> delay3[27:24], C ddr_a[7] <=> delay3[31:28] C ddr_a[8] <=> delay4[3:0], C ddr_a[9] <=> delay4[7:4], ..., C ddr_a[12] <=> delay4[19:16], C ddr_a[13] <=> delay4[23:20] ? ebi (ddrsdrc\hsmc3\nandflash) d[15:0] controlled by 2 registers, delay1 and delay2, located in the hsmc3 user interface C d[0] <=> delay1[3:0], C d[1] <=> delay1[7:4],..., C d[6] <=> delay1[27:24], C d[7] <=> delay1[31:28] C d[8] <=> delay2[3:0], C d[9] <=> delay2[7:4],..., C d[14] <=> delay2[27:24], C d[15] <=> delay2[31:28] d[31,16]on pioc[31:16] controlled by 2 registers, delay3 and delay4, located in the hsmc3 user interface C d[16] <=> delay3[3:0], C d[17] <=> delay3[7:4],..., C d[22] <=> delay3[27:24], C pc[23] <=> delay3[31:28]
19 6438fCatarmC21-jun-10 at91sam9g45 C d[24] <=> delay4[3:0], C d[25] <=> delay4[7:4],..., C d[30] <=> delay4[27:24], C d[31] <=> delay4[31:28] a[25:0] , controlled by 4 registers, delay5, delay6, delay7and delay8, located in the hsmc3 user interface C a[0] <=> delay5[3:0], C a[1] <=> delay5[7:4],..., C a[6] <=> delay5[27:24], C a[7] <=> delay5[31:28] C a[8] <=> delay6[3:0], C a[9] <=> delay6[7:4],..., C a[14] <=> delay6[27:24], C a[15] <=> delay6[31:28] C a[16] <=> delay7[3:0], C a[17] <=> delay7[7:4], C a[18] <=> delay7[11:8] a25 on pc[12] and a[24:19] on pc[7:2] C a19 <=> delay7[15:12], C a20 <=> delay7[19:16],..., C a23 <=> delay7[31:28], C a24 <=> delay8[3:0], C a25 <=> delay8[7:4] ? pioa user interface the delay can only be inserted on the hsmci0 and hsmci1 i/o lines, so on pa[9:2] and pa[30:23]. the delay is controlled by 2 registers, delay1 and delay2, located in the pioa user interface. C pa[2] <=> delay1[3:0], C pa[3] <=> delay1[7:4],..., C pa[8] <=> delay1[27:24], C pa[9] <=> delay1[31:28] C pa[23] <=> delay2[3:0], C pa[24] <=> delay2[7:4],..., C pa[29] <=> delay2[27:24], C pa[30] <=> delay2[31:28] 7. system controller the system controller is a set of peripherals that allows handling of key elements of the system, such as power, resets, clocks, time, interrupts, watchdog, etc.
20 6438fCatarmC21-jun-10 at91sam9g45 the system controller user interface also embeds the registers that configure the matrix and a set of registers for the chip configuration. the chip configuration registers configure the ebi chip select assignment and voltage range for external memories. 7.1 system controller mapping the system controllers peripherals are all mapped within the highest 16 kbytes of address space, between addresses 0xffff e800 and 0xffff ffff. however, all the registers of the system controller are mapped on the top of the address space. all the registers of the system controller can be addressed from a single pointer by using the standard arm instruction set, as the load/store instruction have an indexing mode of 4 kb. figure 7-1 on page 21 shows the system controller block diagram. figure 6-1 on page 15 shows the mapping of the user interfaces of the system controller peripherals.
21 6438fCatarmC21-jun-10 at91sam9g45 7.2 system controller block diagram figure 7-1. at91sam9g45 system cont roller block diagram nrst slck advanced interrupt controller real-time timer periodic interval timer reset controller pa0-pa31 periph_nreset system controller watchdog timer wdt_fault wdrproc pio controllers power management controller xin xout mainck pllack pit_irq mck proc_nreset wdt_irq periph_irq[2..6] periph_nreset periph_clk[2..30] pck mck pmc_irq nirq nfiq rtt_irq embedded peripherals periph_clk[2..6] pck[0-1] in out enable arm926ej-s slck slck irq fiq irq0-irq2 fiq periph_irq[6..30] periph_irq[2..24] int int periph_nreset periph_clk[6..30] jtag_nreset por_ntrst proc_nreset periph_nreset dbgu_txd dbgu_rxd pit_irq dbgu_irq pmc_irq rstc_irq wdt_irq rstc_irq slck boundary scan tap controller jtag_nreset debug pck debug idle debug bus matrix mck periph_nreset proc_nreset backup_nreset periph_nreset idle debug unit dbgu_irq mck dbgu_rxd periph_nreset dbgu_txd rtt_alarm shut-down controller slck rtt0_alarm backup_nreset shdn wkup 4 general-purpose backup registers backup_nreset xin32 xout32 pb0-pb31 pc0-pc31 vddbu powered vddcore powered ntrst vddcore por 12mhz main osc plla vddbu por slow clock osc upll por_ntrst vddbu rtt_irq upllck usb high speed device port upllck periph_nreset periph_irq[24] rc osc pd0-pd31 sckcr pe0-pe31 real-time clock rtc_irq slck backup_nreset rtc_alarm usb high speed host port upllck periph_nreset periph_irq[25] uhp48m uhp12m uhp48m uhp12m ddr sysclk
22 6438fCatarmC21-jun-10 at91sam9g45 7.3 chip identification the at91sam9g45 chip id is defined in the debu g unit chip id regist er and debug unit chip id extension register. ? chip id: 0x819b05a2 ? ext id: 0x00000004 ? jtag id: 05b2_703f ? arm926 tap id: 0x0792603f 7.4 backup section the at91sam9g45 features a backup section that embeds: ? rc oscillator ? slow clock oscillator ? sckr register ?rtt ?rtc ? shutdown controller ? 4 backup registers ? a part of rstc this section is powered by the vddbu rail.
23 6438fCatarmC21-jun-10 at91sam9g45 8. peripherals 8.1 peripheral mapping as shown in figure 6-1 , the peripherals are mapped in the upper 256 mbytes of the address space between the addresses 0xfff7 8000 and 0xfffc ffff. each user peripheral is allocated 16k bytes of address space. 8.2 peripheral identifiers table 8-1 defines the peripheral identifiers of the at91sam9g45. a peripheral identifier is required for the control of the peripheral interrupt with the advanced interrupt controller and for the control of the peripheral clock with the power management controller. table 8-1. at91sam9g45 peripheral identifiers peripheral id peripheral mnemonic peripheral name external interrupt 0aic advanced interrupt controller fiq 1sysc system controller interrupt 2pioa parallel i/o controller a, 3 piob parallel i/o controller b 4 pioc parallel i/o controller c 5 piod/pioe parallel i/o controller d/e 6 trng true random number generator 7us0 usart 0 8us1 usart 1 9us2 usart 2 10 us3 usart 3 11 mci0 high speed multimedia card interface 0 12 twi0 two-wire interface 0 13 twi1 two-wire interface 1 14 spi0 serial peripheral interface 15 spi1 serial peripheral interface 16 ssc0 synchronous serial controller 0 17 ssc1 synchronous serial controller 1 18 tc0..tc5 timer counter 0,1,2,3,4,5 19 pwm pulse width modulation controller 20 tsadcc touch screen adc controller 21 dma dma controller 22 uhphs usb host high speed 23 lcdc lcd controller 24 ac97c ac97 controller 25 emac ethernet mac 26 isi image sensor interface 27 udphs usb device high speed 29 mci1 high speed multimedia card interface 1 30 reserved 31 aic advanced interrupt controller irq
24 6438fCatarmC21-jun-10 at91sam9g45 8.3 peripheral interr upts and clock control 8.3.1 system interrupt the system interrupt in source 1 is the wired-or of the interrupt signals coming from: ? the ddr2/lpddr controller ? the debug unit ? the periodic interval timer ? the real-time timer ? the real-time clock ? the watchdog timer ? the reset controller ? the power management controller the clock of these peripherals cannot be deacti vated and peripheral id 1 can only be used within the advanced interrupt controller. 8.3.2 external interrupts all external interrupt signals, i.e., the fast interr upt signal fiq or the interrupt signal irq, use a dedicated peripheral id. however, there is no clock control associated with these peripheral ids. 8.4 peripheral signals mu ltiplexing on i/o lines the at91sam9g45 features 5 pio controllers, pioa, piob, pioc, piod and pioe, which mul- tiplexes the i/o lines of the peripheral set. each pio controller controls up to 32 lines. each line can be assigned to one of two peripheral functions, a or b. the multiplexing tables in the following paragraphs define how the i/o lines of the peripherals a and b are multiplexed on the pio controllers. the two columns function and comments have been inserted in this table for the users own comments; they may be used to track how pins are defined in an application. note that some peripheral function which are output only, might be duplicated within the both tables. the column reset state indicates whether the pio line resets in i/o mode or in peripheral mode. if i/o is mentioned, the pio line resets in input with the pull-up enabled, so that the device is maintained in a static state as soon as the reset is released. as a result, the bit corre- sponding to the pio line in the register pio_ psr (peripheral status register) resets low. if a signal name is mentioned in the reset stat e column, the pio line is assigned to this func- tion and the corresponding bit in pio_psr resets high. this is the case of pins controlling memories, in particular the address lines, which requ ire the pin to be driven as soon as the reset is released. note that the pull-up resistor is also enabled in this case. to amend emc, programmable delay has been inserted on pio lines able to run at high speed.
25 6438fCatarmC21-jun-10 at91sam9g45 8.4.1 pio controller a multiplexing table 8-2. multiplexing on pi o controller a (pioa) i/o line peripheral a peripheral b reset state power supply function comments pa0 mci0_ck tclk3 i/o vddiop0 pa1 mci0_cda tioa3 i/o vddiop0 pa2 mci0_da0 tiob3 i/o vddiop0 pa3 mci0_da1 tckl4 i/o vddiop0 pa4 mci0_da2 tioa4 i/o vddiop0 pa5 mci0_da3 tiob4 i/o vddiop0 pa6 mci0_da4 etx2 i/o vddiop0 pa7 mci0_da5 etx3 i/o vddiop0 pa8 mci0_da6 erx2 i/o vddiop0 pa9 mci0_da7 erx3 i/o vddiop0 pa10 etx0 i/o vddiop0 pa11 etx1 i/o vddiop0 pa12 erx0 i/o vddiop0 pa13 erx1 i/o vddiop0 pa14 etxen i/o vddiop0 pa15 erxdv i/o vddiop0 pa16 erxer i/o vddiop0 pa17 etxck i/o vddiop0 pa18 emdc i/o vddiop0 pa19 emdio i/o vddiop0 pa20 twd0 i/o vddiop0 pa21 twck0 i/o vddiop0 pa22 mci1_cda sck3 i/o vddiop0 pa23 mci1_da0 rts3 i/o vddiop0 pa24 mci1_da1 cts3 i/o vddiop0 pa25 mci1_da2 pwm3 i/o vddiop0 pa26 mci1_da3 tiob2 i/o vddiop0 pa27 mci1_da4 etxer i/o vddiop0 pa28 mci1_da5 erxck i/o vddiop0 pa29 mci1_da6 ecrs i/o vddiop0 pa30 mci1_da7 ecol i/o vddiop0 pa31 mci1_ck pck0 i/o vddiop0
26 6438fCatarmC21-jun-10 at91sam9g45 8.4.2 pio controller b multiplexing table 8-3. multiplexing on pi o controller b (piob) i/o line peripheral a peripheral b reset state power supply function comments pb0 spi0_miso i/o vddiop0 pb1 spi0_mosi i/o vddiop0 pb2 spi0_spck i/o vddiop0 pb3 spi0_npcs0 i/o vddiop0 pb4 txd1 i/o vddiop0 pb5 rxd1 i/o vddiop0 pb6 txd2 i/o vddiop0 pb7 rxd2 i/o vddiop0 pb8 txd3 isi_d8 i/o vddiop2 pb9 rxd3 isi_d9 i/o vddiop2 pb10 twd1 isi_d10 i/o vddiop2 pb11 twck1 isi_d11 i/o vddiop2 pb12 drxd i/o vddiop0 pb13 dtxd i/o vddiop0 pb14 spi1_miso i/o vddiop0 pb15 spi1_mosi cts0 i/o vddiop0 pb16 spi1_spck sck0 i/o vddiop0 pb17 spi1_npcs0 rts0 i/o vddiop0 pb18 rxd0 spi0_npcs1 i/o vddiop0 pb19 txd0 spi0_npcs2 i/o vddiop0 pb20 isi_d0 i/o vddiop2 pb21 isi_d1 i/o vddiop2 pb22 isi_d2 i/o vddiop2 pb23 isi_d3 i/o vddiop2 pb24 isi_d4 i/o vddiop2 pb25 isi_d5 i/o vddiop2 pb26 isi_d6 i/o vddiop2 pb27 isi_d7 i/o vddiop2 pb28 isi_pck i/o vddiop2 pb29 isi_vsync i/o vddiop2 pb30 isi_hsync i/o vddiop2 pb31 isi_mck pck1 i/o vddiop2
27 6438fCatarmC21-jun-10 at91sam9g45 8.4.3 pio controller c multiplexing table 8-4. multiplexing on pi o controller c (pioc) i/o line peripheral a peripheral b reset state power supply function comments pc0 dqm2 dqm2 vddiom1 pc1 dqm3 dqm3 vddiom1 pc2 a19 a19 vddiom1 pc3 a20 a20 vddiom1 pc4 a21/nandale a21 vddiom1 pc5 a22/nandcle a22 vddiom1 pc6 a23 a23 vddiom1 pc7 a24 a24 vddiom1 pc8 cfce1 i/o vddiom1 pc9 cfce2 rts2 i/o vddiom1 pc10 ncs4/cfcs0 tclk2 i/o vddiom1 pc11 ncs5/cfcs1 cts2 i/o vddiom1 pc12 a25/cfrnw a25 vddiom1 pc13 ncs2 i/o vddiom1 pc14 ncs3/nandcs i/o vddiom1 pc15 nwait i/o vddiom1 pc16 d16 i/o vddiom1 pc17 d17 i/o vddiom1 pc18 d18 i/o vddiom1 pc19 d19 i/o vddiom1 pc20 d20 i/o vddiom1 pc21 d21 i/o vddiom1 pc22 d22 i/o vddiom1 pc23 d23 i/o vddiom1 pc24 d24 i/o vddiom1 pc25 d25 i/o vddiom1 pc26 d26 i/o vddiom1 pc27 d27 i/o vddiom1 pc28 d28 i/o vddiom1 pc29 d29 i/o vddiom1 pc30 d30 i/o vddiom1 pc31 d31 i/o vddiom1
28 6438fCatarmC21-jun-10 at91sam9g45 8.4.4 pio controller d multiplexing table 8-5. multiplexing on pi o controller d (piod) i/o line peripheral a peripheral b reset state power supply function comments pd0 tk0 pwm3 i/o vddiop0 pd1 tf0 i/o vddiop0 pd2 td0 i/o vddiop0 pd3 rd0 i/o vddiop0 pd4 rk0 i/o vddiop0 pd5 rf0 i/o vddiop0 pd6 ac97rx i/o vddiop0 pd7 ac97tx tioa5 i/o vddiop0 pd8 ac97fs tiob5 i/o vddiop0 pd9 ac97ck tclk5 i/o vddiop0 pd10 td1 i/o vddiop0 pd11 rd1 i/o vddiop0 pd12 tk1 pck0 i/o vddiop0 pd13 rk1 i/o vddiop0 pd14 tf1 i/o vddiop0 pd15 rf1 i/o vddiop0 pd16 rts1 i/o vddiop0 pd17 cts1 i/o vddiop0 pd18 spi1_npcs2 irq i/o vddiop0 pd19 spi1_npcs3 fiq i/o vddiop0 pd20 tioa0 i/o vddana tsad0 pd21 tioa1 i/o vddana tsad1 pd22 tioa2 i/o vddana tsad2 pd23 tclk0 i/o vddana tsad3 pd24 spi0_npcs1 pwm0 i/o vddana gpad4 pd25 spi0_npcs2 pwm1 i/o vddana gpad5 pd26 pck0 pwm2 i/o vddana gpad6 pd27 pck1 spi0_npcs3 i/o vddana gpad7 pd28 tsadtrg spi1_npcs1 i/o vddiop0 pd29 tclk1 sck1 i/o vddiop0 pd30 tiob0 sck2 i/o vddiop0 pd31 tiob1 pwm1 i/o vddiop0
29 6438fCatarmC21-jun-10 at91sam9g45 8.4.5 pio controller e multiplexing table 8-6. multiplexing on pi o controller e (pioe) i/o line peripheral a peripheral b reset state power supply function comments pe0 lcdpwr pck0 i/o vddiop1 pe1 lcdmod i/o vddiop1 pe2 lcdcc i/o vddiop1 pe3 lcdvsync i/o vddiop1 pe4 lcdhsync i/o vddiop1 pe5 lcddotck i/o vddiop1 pe6 lcdden i/o vddiop1 pe7 lcdd0 lcdd2 i/o vddiop1 pe8 lcdd1 lcdd3 i/o vddiop1 pe9 lcdd2 lcdd4 i/o vddiop1 pe10 lcdd3 lcdd5 i/o vddiop1 pe11 lcdd4 lcdd6 i/o vddiop1 pe12 lcdd5 lcdd7 i/o vddiop1 pe13 lcdd6 lcdd10 i/o vddiop1 pe14 lcdd7 lcdd11 i/o vddiop1 pe15 lcdd8 lcdd12 i/o vddiop1 pe16 lcdd9 lcdd13 i/o vddiop1 pe17 lcdd10 lcdd14 i/o vddiop1 pe18 lcdd11 lcdd15 i/o vddiop1 pe19 lcdd12 lcdd18 i/o vddiop1 pe20 lcdd13 lcdd19 i/o vddiop1 pe21 lcdd14 lcdd20 i/o vddiop1 pe22 lcdd15 lcdd21 i/o vddiop1 pe23 lcdd16 lcdd22 i/o vddiop1 pe24 lcdd17 lcdd23 i/o vddiop1 pe25 lcdd18 i/o vddiop1 pe26 lcdd19 i/o vddiop1 pe27 lcdd20 i/o vddiop1 pe28 lcdd21 i/o vddiop1 pe29 lcdd22 i/o vddiop1 pe30 lcdd23 i/o vddiop1 pe31 pwm2 pck1 i/o vddiop1
30 6438fCatarmC21-jun-10 at91sam9g45
31 6438fCatarmC21-jun-10 at91sam9g45 9. arm926ej-s processor overview 9.1 description the arm926ej-s ? processor is a member of the arm9 ? family of general-purpose micropro- cessors. the arm926ej-s implements arm architec ture version 5tej and is targeted at multi- tasking applications where full memory management, high performance, low die size and low power are all important features. the arm926ej-s processor supports the 32- bit arm and 16-bit thumb instruction sets, enabling the user to trade off between high performance and high code density. it also supports 8-bit java instruction set and includes features fo r efficient execution of java bytecode, provid- ing a java performance similar to a jit (just-in-time compilers), for the next generation of java- powered wireless and embedded devices. it includes an enhanced multiplier design for improved dsp performance. the arm926ej-s processor supports the arm debug architecture and includes logic to assist in both hardware and software debug. the arm926ej-s provides a complete high performance processor subsystem, including: ? an arm9ej-s integer core ? a memory management unit (mmu) ? separate instruction and data amba ahb bus interfaces ? separate instruction and data tcm interfaces
32 6438fCatarmC21-jun-10 at91sam9g45 9.2 embedded characteristics ? risc processor based on arm v5tej archit ecture with jazelle technology for java acceleration ? two instruction sets C arm high-performance 32-bit instruction set C thumb high code density 16-bit instruction set ? dsp instruction extensions ? 5-stage pipeline architecture: C instruction fetch (f) C instruction decode (d) C execute (e) C data memory (m) C register write (w) ? 32-kbyte data cache, 32-kbyte instruction cache C virtually-addressed 4-way associative cache C eight words per line C write-through and write-back operation C pseudo-random or round-robin replacement ? write buffer C main write buffer with 16-word data buffer and 4-address buffer C dcache write-back buffer with 8-word entries and a single address entry C software control drain ? standard arm v4 and v5 memory management unit (mmu) C access permission for sections C access permission for large pages and small pages can be specified separately for each quarter of the page C 16 embedded domains ? bus interface unit (biu) C arbitrates and schedules ahb requests C separate masters for both instruction and data access providin g complete matrix system flexibility C separate address and data buses for both the 32-bit instruction interface and the 32-bit data interface C on address and data buses, data can be 8-bit (bytes), 16-bit (half-words) or 32-bit (words) ? tcm interface
33 6438fCatarmC21-jun-10 at91sam9g45 9.3 block diagram figure 9-1. arm926ej-s internal functional block diagram cp15 system configuration coprocessor external coprocessor interface trace port interface arm9ej-s processor core dtcm interface data tlb instruction tlb itcm interface data cache ahb interface and write buffer instruction cache write data read data instruction fetches data address instruction address data address instruction address instruction tcm data tcm mmu amba ahb external coprocessors etm9
34 6438fCatarmC21-jun-10 at91sam9g45 9.4 arm9ej-s processor 9.4.1 arm9ej-s operating states the arm9ej-s processor can operate in three different states, each with a specific instruction set: ? arm state: 32-bit, word-aligned arm instructions. ? thumb state: 16-bit, halfword-aligned thumb instructions. ? jazelle state: variable length, byte-aligned jazelle instructions. in jazelle state, all instru ction fetches are in words. 9.4.2 switching state the operating state of the arm9ej-s core can be switched between: ? arm state and thumb state using the bx and blx instructions, and loads to the pc ? arm state and jazelle state using the bxj instruction all exceptions are entered, handled and exited in arm state. if an exception occurs in thumb or jazelle states, the processor reverts to arm state. the transition back to thumb or jazelle states occurs automatically on return from the exception handler. 9.4.3 instruction pipelines the arm9ej-s core uses two kinds of pipelines to increase the speed of the flow of instructions to the processor. a five-stage (five clock cycles) pipeline is used for arm and thumb states. it consists of fetch, decode, execute, memory and writeback stages. a six-stage (six clock cycles) pipeline is us ed for jazelle state it consists of fetch, jazelle/decode (two clock cycles), execute, memory and writeback stages. 9.4.4 memory access the arm9ej-s core supports byte (8-bit), half-word (16-bit) and word (32-bit) access. words must be aligned to four-byte boundaries, half-words must be aligned to two-byte boundaries and bytes can be placed on any byte boundary. because of the nature of the pipelines, it is possible for a value to be required for use before it has been placed in the register bank by the actions of an earlier instruction. the arm9ej-s con- trol logic automatically detects these cases and stalls the core or forward data. 9.4.5 jazelle technology the jazelle technology enables direct and efficient execution of java byte codes on arm pro- cessors, providing high performance for the next generation of java-powered wireless and embedded devices. the new java feature of arm9ej-s can be described as a hardware emulation of a jvm (java virtual machine). java mode will appear as another state: instead of executing arm or thumb instructions, it executes java byte codes. the java byte code decoder logic implemented in arm9ej-s decodes 95% of executed byte codes and turns them into ar m instructions without any overhead, while less frequently used byte codes are broken down into optimized sequences of arm instructions. the hardware/software split is invisible to the programmer, invisible to the application and invisible to the operating system . all existing arm registers are re-used in jazelle state and all registers then have particular functions in this mode.
35 6438fCatarmC21-jun-10 at91sam9g45 minimum interrupt latency is maintained across both arm state and java state. since byte codes execution can be restarted, an interrupt automatically triggers the core to switch from java state to arm state for the execution of the interrupt handler. this means that no special provision has to be made for handling interrupts while executing byte codes, whether in hard- ware or in software. 9.4.6 arm9ej-s operating modes in all states, there are seven operation modes: ? user mode is the usual arm program executio n state. it is used for executing most application programs ? fast interrupt (fiq) mode is used for handling fast interrupts. it is suitable for high-speed data transfer or channel process ? interrupt (irq) mode is used for general-purpose interrupt handling ? supervisor mode is a protected mode for the operating system ? abort mode is entered after a data or instruction prefetch abort ? system mode is a privileged user mode for the operating system ? undefined mode is entered when an undefined instruction exception occurs mode changes may be made under software control, or may be brought about by external inter- rupts or exception processing. most application programs execute in user mode. the non-user modes, known as privileged modes, are entered in or der to service interrupts or exceptions or to access protecte d resources. 9.4.7 arm9ej-s registers the arm9ej-s core has a total of 37 registers. ? 31 general-purpose 32-bit registers ? 6 32-bit status registers table 9-1 shows all the registers in all modes. table 9-1. arm9tdmi modes and registers layout user and system mode supervisor mode abort mode undefined mode interrupt mode fast interrupt mode r0 r0 r0 r0 r0 r0 r1 r1 r1 r1 r1 r1 r2 r2 r2 r2 r2 r2 r3 r3 r3 r3 r3 r3 r4 r4 r4 r4 r4 r4 r5 r5 r5 r5 r5 r5 r6 r6 r6 r6 r6 r6 r7 r7 r7 r7 r7 r7 r8 r8 r8 r8 r8 r8_fiq r9 r9 r9 r9 r9 r9_fiq r10 r10 r10 r10 r10 r10_fiq r11 r11 r11 r11 r11 r11_fiq
36 6438fCatarmC21-jun-10 at91sam9g45 the arm state register set contains 16 directly-a ccessible registers, r0 to r15, and an additional register, the current program status register (cpsr). registers r0 to r13 are general-purpose registers used to hold either data or address va lues. register r14 is used as a link register that holds a value (return address) of r15 when bl or blx is executed. register r15 is used as a pro- gram counter (pc), whereas the current program status register (cpsr) contains condition code flags and the current mode bits. in privileged modes (fiq, supervisor, abort, irq, undefined), mode-specific banked registers (r8 to r14 in fiq mode or r13 to r14 in the other modes) become available. the corresponding banked registers r14_fiq, r14_svc, r14_abt, r14_irq, r14_und are similarly used to hold the val- ues (return address for each mode) of r15 (pc) when interrupts and exceptions arise, or when bl or blx instructions are executed within interrupt or exception routines. there is another reg- ister called saved program status register (spsr) that becomes available in privileged modes instead of cpsr. this register contains condition code flags and the current mode bits saved as a result of the exception that caused entry to the current (privileged) mode. in all modes and due to a software agreement, register r13 is used as stack pointer. the use and the function of all the registers described above should obey arm procedure call standard (apcs) which defines: ? constraints on the use of registers ? stack conventions ? argument passing and result return for more details, refer to arm software development kit. the thumb state register set is a subset of the arm state set. the programmer has direct access to: ? eight general-purpose registers r0-r7 ? stack pointer, sp ? link register, lr (arm r14) ?pc r12 r12 r12 r12 r12 r12_fiq r13 r13_svc r13_abort r13_undef r13_irq r13_fiq r14 r14_svc r14_abort r14_undef r14_irq r14_fiq pc pc pc pc pc pc cpsr cpsr cpsr cpsr cpsr cpsr spsr_svc spsr_abor t spsr_unde f spsr_irq spsr_fiq mode-specific banked registers table 9-1. arm9tdmi modes and registers layout user and system mode supervisor mode abort mode undefined mode interrupt mode fast interrupt mode
37 6438fCatarmC21-jun-10 at91sam9g45 ? cpsr there are banked re gisters sps, lrs and spsrs for each priv ileged mode (for more details see the arm9ej-s technical reference manual, revision r1p2 page 2-12). 9.4.7.1 status registers the arm9ej-s core contains one cpsr, and fi ve spsrs for exception handlers to use. the program status registers: ? hold information about the most recently performed alu operation ? control the enabling and disabling of interrupts ? set the processor operation mode figure 9-2. status register format figure 9-2 shows the status register format, where: ? n: negative, z: zero, c: carry, and v: overflow are the four alu flags ? the sticky overflow (q) flag can be set by certain multiply and fractional arithmetic instructions like qadd, qdadd, qsub, qdsub, smlaxy, and smlawy needed to achieve dsp operations. the q flag is sticky in that, when set by an instru ction, it remains set unt il explicitly cleared by an msr instruction writing to the cpsr. instructions cannot execute conditionally on the status of the q flag. ? the j bit in the cpsr indicates when the ar m9ej-s core is in jazelle state, where: C j = 0: the processor is in arm or thumb state, depending on the t bit C j = 1: the processor is in jazelle state. ? mode: five bits to encode the current processor mode 9.4.7.2 exceptions 9.4.7.3 exception types and priorities the arm9ej-s supports five types of exceptions. each type drives the arm9ej-s in a privi- leged mode. the types of exceptions are: ? fast interrupt (fiq) ? normal interrupt (irq) ? data and prefetched aborts (abort) ? undefined instruction (undefined) ? software interrupt and reset (supervisor) nz cv q jift mode reserved mode bits thumb state bit fiq disable irq disable jazelle state bit reserved sticky overflow overflow carry/borrow/extend zero negative/less than 31 30 29 28 27 24 7 6 5 0
38 6438fCatarmC21-jun-10 at91sam9g45 when an exception occurs, the banked version of r14 and the spsr for the exception mode are used to save the state. more than one exception can happen at a time, therefore the arm9ej-s takes the arisen excep- tions according to the following priority order: ? reset (highest priority) ? data abort ?fiq ?irq ?prefetch abort ? bkpt, undefined instruction, and softwa re interrupt (swi) (lowest priority) the bkpt, or undefined instruction, and swi exceptions are mutually exclusive. note that there is one exception in the priority scheme: when fiqs are enabled and a data abort occurs at the same time as an fiq, the arm9ej-s core enters the data abort handler, and pro- ceeds immediately to fiq vector. a normal return from the fiq causes the data abort handler to resume execution. data aborts must have higher priority than fiqs to ensure that the transfer error does not escape detection. 9.4.7.4 exception modes and handling exceptions arise whenever the normal flow of a program must be halted temporarily, for exam- ple, to service an interrupt from a peripheral. when handling an arm exception, the arm9ej-s core performs the following operations: 1. preserves the address of the next instruction in the appropriate link register that cor- responds to the new mode that has been entered. when the exception entry is from: C arm and jazelle states, the arm9ej-s copies the address of the next instruction into lr (current pc(r15) + 4 or pc + 8 depending on the exception). C thumb state, the arm9ej-s writes the value of the pc into lr, offset by a value (current pc + 2, pc + 4 or pc + 8 depending on the exception) that causes the program to resume from the correct place on return. 2. copies the cpsr into the appropr iate spsr. 3. forces the cpsr mode bits to a value that depends on the exception. 4. forces the pc to fetch the next instruction from the relevant exception vector. the register r13 is also banked across exception modes to provide each exception handler with private stack pointer. the arm9ej-s can also set the interrupt disable flags to prevent otherwise unmanageable nesting of exceptions. when an exception has completed, the exception handler must move both the return value in the banked lr minus an offset to the pc and the spsr to the cpsr. t he offset value varies according to the type of exception. this action restores both pc and the cpsr. the fast interrupt mode has seven private registers r8 to r14 (banked registers) to reduce or remove the requirement for register saving wh ich minimizes the overhead of context switching. the prefetch abort is one of the aborts that indicates that the current memory access cannot be completed. when a prefetch abort occurs, the arm9ej-s marks the prefetched instruction as invalid, but does not take the exception until th e instruction reaches the execute stage in the
39 6438fCatarmC21-jun-10 at91sam9g45 pipeline. if the instruction is not executed, for ex ample because a branch occurs while it is in the pipeline, the abort does not take place. the breakpoint (bkpt) instruction is a new feat ure of arm9ej-s that is destined to solve the problem of the prefetch abort. a breakpoint instruction operates as though the instruction caused a prefetch abort. a breakpoint instruction does not cause the arm9ej-s to take the prefetch abort exception until the instruction reaches the execute stage of the pi peline. if the instruction is not executed, for example because a branch occurs while it is in the pipeline, the breakpoint does not take place. 9.4.8 arm instruction set overview the arm instruction set is divided into: ? branch instructions ? data processing instructions ? status register transfer instructions ? load and store instructions ? coprocessor instructions ? exception-generating instructions arm instructions can be executed conditionally. every instruction contains a 4-bit condition code field (bits[31:28]). for further details, see the arm technical reference manual. table 9-2 gives the arm instruction mnemonic list. table 9-2. arm instruction mnemonic list mnemonic operation mnemonic operation mov move mvn move not add add adc add with carry sub subtract sbc subtract with carry rsb reverse subtract rsc reverse subtract with carry cmp compare cmn compare negated tst test teq test equivalence and logical and bic bit clear eor logical exclusive or or r logical (inclusive) or mul multiply mla multiply accumulate smull sign long multiply umull unsigned long multiply smlal signed long multiply accumulate umlal unsigned long multiply accumulate msr move to status register mrs move from status register b branch bl branch and link bx branch and exchange swi software interrupt ldr load word str store word ldrsh load signed halfword ldrsb load signed byte
40 6438fCatarmC21-jun-10 at91sam9g45 9.4.9 new arm instruction set . notes: 1. a thumb blx contains two consecutiv e thumb instructions, and takes four cycles. 9.4.10 thumb instruction set overview the thumb instruction set is a re-encoded subset of the arm instruction set. the thumb instruction set is divided into: ? branch instructions ? data processing instructions ? load and store instructions ? load and store multiple instructions ldrh load half word strh store half word ldrb load byte strb store byte ldrbt load register byte with translation strbt store register byte with translation ldrt load register with translation st rt store register with translation ldm load multiple stm store multiple swp swap word swpb swap byte mcr move to coprocessor mrc move from coprocessor ldc load to coprocessor stc store from coprocessor cdp coprocessor data processing table 9-2. arm instruction mnemonic list (continued) mnemonic operation mnemonic operation table 9-3. new arm instruction mnemonic list mnemonic operation mnemonic operation bxj branch and exchange to java mrrc move double from coprocessor blx (1) branch, link and exchange mcr2 alternative move of arm reg to coprocessor smlaxy signed multiply accumulate 16 * 16 bit mcrr move double to coprocessor smlal signed multiply accumulate long cdp2 alternative coprocessor data processing smlawy signed multiply accumulate 32 * 16 bit bkpt breakpoint smulxy signed multiply 16 * 16 bit pld soft preload, memory prepare to load from address smulwy signed multiply 32 * 16 bit strd store double qadd saturated add stc2 alternative store from coprocessor qdadd saturated add with double ldrd load double qsub saturated subtract ldc2 alternative load to coprocessor qdsub saturated subtract with double clz count leading zeroes
41 6438fCatarmC21-jun-10 at91sam9g45 ? exception-generating instruction table 5 shows the thumb instruction set, for further details, see the arm technical reference manual. table 9-4 gives the thumb instruction mnemonic list. table 9-4. thumb instruction mnemonic list mnemonic operation mnemonic operation mov move mvn move not addadd adcadd with carry sub subtract sbc subtract with carry cmp compare cmn compare negated tst test neg negate and logical and bic bit clear eor logical exclus ive or orr logical (inclusive) or lsl logical shift left lsr logical shift right asr arithmetic shift right ror rotate right mul multiply blx branch, link, and exchange b branch bl branch and link bx branch and exchange swi software interrupt ldr load word str store word ldrh load half word strh store half word ldrb load byte strb store byte ldrsh load signed halfword ldrsb load signed byte ldmia load multiple stmia store multiple push push register to stack pop pop register from stack bcc conditional branch bkpt breakpoint
42 6438fCatarmC21-jun-10 at91sam9g45 9.5 cp15 coprocessor coprocessor 15, or system control coprocessor cp15, is used to configure and control all the items in the list below: ? arm9ej-s ? caches (icache, dcache and write buffer) ?tcm ?mmu ? other system options to control these features, cp15 provides 16 additional registers. see table 9-5 . notes: 1. register locations 0,5, and 13 each provid e access to more than one register. the register accessed depends on the value of the opcode_2 field. 2. register location 9 provides access to more than one register. the register accessed depends on the value of the crm field. table 9-5. cp15 registers register name read/write 0 id code (1) read/unpredictable 0 cache type (1) read/unpredictable 0 tcm status (1) read/unpredictable 1 control read/write 2 translation table base read/write 3 domain access control read/write 4 reserved none 5 data fault status (1) read/write 5 instruction fault status (1) read/write 6 fault address read/write 7 cache operations read/write 8 tlb operations unpredictable/write 9 cache lockdown (2) read/write 9 tcm region read/write 10 tlb lockdown read/write 11 reserved none 12 reserved none 13 fcse pid (1) read/write 13 context id (1) read/write 14 reserved none 15 test configuration read/write
43 6438fCatarmC21-jun-10 at91sam9g45 9.5.1 cp15 registers access cp15 registers can only be accessed in privileged mode by: ? mcr (move to coprocessor from arm register) instruction is used to write an arm register to cp15. ? mrc (move to arm register from coprocessor) instruction is used to read the value of cp15 to an arm register. other instructions like cdp, ldc, stc can cause an undefined instruction exception. the assembler code for these instructions is: mcr/mrc{cond} p15, opcode_1, rd, crn, crm, opcode_2. the mcr, mrc instructions bit pattern is shown below: ? crm[3:0]: specified coprocessor action determines specific coprocessor action. its value is dependen t on the cp15 register used. for details, refer to cp15 spe- cific register behavior. ? opcode_2[7:5] determines specific coprocessor operation code. by default, set to 0. ? rd[15:12]: arm register defines the arm register whose value is transferred to the co processor. if r15 is chosen, the result is unpredictable. ? crn[19:16]: coprocessor register determines the destination coprocessor register. ? l: instruction bit 0 = mcr instruction 1 = mrc instruction ? opcode_1[23:20]: coprocessor code defines the coprocessor specific code. value is c15 for cp15. ? cond [31:28]: condition for more details, see chapter 2 in arm926ej-s trm. 31 30 29 28 27 26 25 24 cond 1110 23 22 21 20 19 18 17 16 opcode_1 l crn 15 14 13 12 11 10 9 8 rd 1111 76543210 opcode_2 1 crm
44 6438fCatarmC21-jun-10 at91sam9g45 9.6 memory management unit (mmu) the arm926ej-s processor implements an enhanced arm architecture v5 mmu to provide vir- tual memory features required by operating systems like symbian os ? , windows ce ? , and linux ? . these virtual memory features are memory access permission controls and virtual to physical address translations. the virtual address generated by the cpu core is converted to a modified virtual address (mva) by the fcse (fast context switch extens ion) using the value in cp15 register13. the mmu translates modified virtual addresses to physical addresses by using a single, two-level page table set stored in physical memory. each entry in the set contains the access permissions and the physical address that correspond to the virtual address. the first level translation tables contain 4096 entries indexed by bits [31:20] of the mva. these entries contain a pointer to either a 1 mb secti on of physical memory along with attribute infor- mation (access permissions, domain, etc.) or an entry in the second level translation tables; coarse table and fine table. the second level translation tables contain tw o subtables, coarse table and fine table. an entry in the coarse table contains a pointer to both large pages and small pages along with access permissions. an entry in the fine table contains a pointer to large, small and tiny pages. table 7 shows the different attributes of each page in the physical memory. the mmu consists of: ? access control logic ? translation look-aside buffer (tlb) ? translation table walk hardware 9.6.1 access control logic the access control logic controls access information for every entry in the translation table. the access control logic checks two pieces of access information: domain and access permissions. the domain is the primary access control mechanism for a memory region; there are 16 of them. it defines the conditions necessary for an access to proceed. the domain determines whether the access permissions are used to qualify the access or whether they should be ignored. the second access control mechanism is access permissions that are defined for sections and for large, small and tiny pages. sections and tiny pages have a single set of access permissions whereas large and small pages can be associated with 4 sets of access permissions, one for each subpage (quarter of a page). 9.6.2 translation look-aside buffer (tlb) the translation look-aside buffer (tlb) caches translated entries and thus avoids going through the translation process every time. when the tlb contains an entry for the mva (modi- table 9-6. mapping details mapping name mapping size access permission by subpage size section 1m byte section - large page 64k bytes 4 separated subpages 16k bytes small page 4k bytes 4 separated subpages 1k byte tiny page 1k byte tiny page -
45 6438fCatarmC21-jun-10 at91sam9g45 fied virtual address), the access control logic dete rmines if the access is permitted and outputs the appropriate physical address corresponding to the mva. if access is not permitted, the mmu signals the cpu core to abort. if the tlb does not contain an entry for the mva, the translation table walk hardware is invoked to retrieve the translation information from the translation table in physical memory. 9.6.3 translation table walk hardware the translation table walk hardware is a logic that traverses the translation tables located in physical memory, gets the ph ysical address and access permissions and updates the tlb. the number of stages in the hardware table walking is one or two depending whether the address is marked as a section-mapped access or a page-mapped access. there are three sizes of page-mapped accesses and one size of section-mapped access. page- mapped accesses are for large pages, small pages and tiny pages. the translation process always begins with a level one fetch. a section-mapped access requires only a level one fetch, but a page-mapped access requires an additional level two fetch. for further details on the mmu, please refer to chapter 3 in arm926ej-s technical reference manual. 9.6.4 mmu faults the mmu generates an abort on the following types of faults: ? alignment faults (for data accesses only) ? translation faults ? domain faults ? permission faults the access control mechanism of the mmu detects the conditions that produce these faults. if the fault is a result of memory access, the mmu aborts the access and signals the fault to the cpu core.the mmu retains status and address information about faults generated by the data accesses in the data fault status register and fault address register. it also retains the status of faults generated by instruction fetches in the instruction fault status register. the fault status register (register 5 in cp15) indicates the cause of a data or prefetch abort, and the domain number of the aborted access when it happens. the fault address register (register 6 in cp15) holds the mva associated with the access that caused the data abort. for further details on mmu faults, please refer to chapte r 3 in arm926ej-s technical reference manual.
46 6438fCatarmC21-jun-10 at91sam9g45 9.7 caches and write buffer the arm926ej-s contains a 32k byte instruction cache (icache), a 32k byte data cache (dcache), and a write buffer. although the icache and dcache share common features, each still has some specific mechanisms. the caches (icache and dcache) are four-way se t associative, addressed, indexed and tagged using the modified virtual address (mva), with a ca che line length of eight words with two dirty bits for the dcache. the icache and dcache provide mechanisms for cache lockdown, cache pollution control, and line replacement. a new feature is now supported by arm926ej-s caches called allocate on read-miss commonly known as wrapping. this feature enables the caches to perform cr itical word first cache refilling. this means that when a request for a word caus es a read-miss, the cache performs an ahb access. instead of loading the whole line (eight words), the cache loads the critical word first, so the processor can reach it quickly, and then the remaining words, no matter where the word is located in the line. the caches and the write buffer are controlled by the cp15 register 1 (control), cp15 register 7 (cache operations) and cp15 register 9 (cache lockdown). 9.7.1 instruction cache (icache) the icache caches fetched instructions to be executed by the processor. the icache can be enabled by writing 1 to i bit of the cp15 register 1 and disabled by writing 0 to this same bit. when the mmu is enabled, all instruction fetches are subject to translation and permission checks. if the mmu is disabled, all instructions fetches are cachable, no protection checks are made and the physical address is flat-mapped to the modified virtual address. with the mva use disabled, context switching incurs icache cleaning and/or invalidating. when the icache is disabled, all instruction fetches appear on external memory (ahb) (see tables 4-1 and 4-2 in page 4-4 in arm926ej-s trm). on reset, the icache entries are invalidated and the icache is disabled. for best performance, icache should be enabled as soon as possible after reset. 9.7.2 data cache (dcache) and write buffer arm926ej-s includes a dcache and a write buffer to reduce the effect of main memory band- width and latency on data access performance. the operations of dcache and write buffer are closely connected. 9.7.2.1 dcache the dcache needs the mmu to be enabled. all data accesses are subject to mmu permission and translation checks. data acce sses that are aborted by the mmu do not cause linefills or data accesses to appear on the amba asb interface. if the mmu is disabled, all data accesses are noncachable, nonbufferable, with no protecti on checks, and appear on the ahb bus. all addresses are flat-mapped, va = mva = pa, whic h incurs dcache cleaning and/or invalidating every time a context switch occurs. the dcache stores the physical address tag (pa tag) from which every line was loaded and uses it when writing modified lines back to external memory. this means that the mmu is not involved in write-back operations. each line (8 words) in the dcache has two dirty bits, one for the first four words and the other one for the second four words. these bits, if set, mark the associated half- lines as dirty. if the
47 6438fCatarmC21-jun-10 at91sam9g45 cache line is replaced due to a linefill or a cache cl ean operation, the dirty bits are used to decide whether all, half or none is written back to memory. dcache can be enabled or disabled by writing either 1 or 0 to bit c in register 1 of cp15 (see tables 4-3 and 4-4 on page 4-5 in arm926ej-s trm). the dcache supports write-through and write-back cache operations, selected by memory region using the c and b bits in the mmu translation tables. the dcache contains an eight data word entr y, single address entry write-back buffer used to hold write-back data for cache line eviction or cleaning of dirty cache lines. the write buffer can hold up to 16 words of data and four separate addresses. dcache and write buffer operations are closely connected as their configuration is set in each section by the page descriptor in the mmu translation table. 9.7.2.2 write buffer the arm926ej-s contains a write buffer that has a 16-word data buffer and a four- address buf- fer. the write buffer is used for all writes to a bufferable region, write-through region and write- back region. it also allows to avoid stalling the processor when writes to external memory are performed. when a store occurs, data is written to the write buffer at core speed (high speed). the write buffer then completes the store to external memory at bus speed (typically slower than the core speed). during this time, the arm9ej-s processor can preform other tasks. dcache and write buffer support write-back and write-through memory regions, controlled by c and b bits in each section and page descriptor within the mmu translation tables. 9.7.2.3 write-though operation when a cache write hit occurs, the dcache line is updated. the updated data is then written to the write buffer which transfers it to external memory. when a cache write miss occurs, a line, chosen by round robin or another algorithm, is stored in the write buffer which transfers it to external memory. 9.7.2.4 write-back operation when a cache write hit occurs, the cache line or half line is marked as dirty, meaning that its contents are not up-to-date with those in the external memory. when a cache write miss occurs, a line, chosen by round robin or another algorithm, is stored in the write buffer which transfers it to external memory.
48 6438fCatarmC21-jun-10 at91sam9g45 9.8 tightly-coupled memory interface 9.8.1 tcm description the arm926ej-s processor features a tightly-co upled memory (tcm) interface, which enables separate instruction and data tcms (itcm and dtcm) to be directly reached by the processor. tcms are used to store real-time and performance critical code, they also provide a dma sup- port mechanism. unlike ahb accesses to external memories, accesses to tcms are fast and deterministic and do not incur bus penalties. the user has the possibility to independently conf igure each tcm size with values within the fol- lowing ranges, [0k byte, 64k bytes] for itcm size and [0k byte, 64k bytes] for dtcm size. tcms can be configured by two means: hmatrix tcm register and tcm region register (regis- ter 9) in cp15 and both steps should be performed. hmatrix tcm register sets tcm size whereas tcm region register (register 9) in cp15 maps tcms and enables them. the data side of the arm9ej-s core is able to access the itcm. this is necessary to enable code to be loaded into the itcm, for swi and emulated instruction handlers, and for accesses to pc-relative literal pools. 9.8.2 enabling and disabling tcms prior to any enabling step, the user should configure the tcm sizes in hmatrix tcm register. then enabling tcms is performed by using tcm r egion register (register 9) in cp15. the user should use the same sizes as those put in hm atrix tcm register. for further details and pro- gramming tips, please refer to chapter 2.3 in arm926ej-s trm. 9.8.3 tcm mapping the tcms can be located anywhere in the memory map, with a single region available for itcm and a separate region available for dtcm. t he tcms are physically addressed and can be placed anywhere in physical address space. however, the base address of a tcm must be aligned to its size, and the dtcm and itcm regions must not overlap. tcm mapping is per- formed by using tcm region register (register 9) in cp15. the user should input the right mapping address for tcms.
49 6438fCatarmC21-jun-10 at91sam9g45 9.9 bus interface unit the arm926ej-s features a bus interface unit (biu) that arbitrates and schedules ahb requests. the biu implements a multi-layer ahb, based on the ahb-lite protocol, that enables parallel access paths between multiple ahb masters and slaves in a system. this is achieved by using a more complex interconnection matrix and gives the benefit of increased overall bus bandwidth, and a more flexible system architecture. the multi-master bus architecture has a number of benefits: ? it allows the development of multi-master systems with an increased bus bandwidth and a flexible architecture. ? each ahb layer becomes simple because it only has one master, so no arbitration or master- to-slave muxing is required. ahb layers, implementing ahb-lite protocol, do not have to support request and grant, nor do they have to support retry and split transactions. ? the arbitration becomes effective when more than one master wants to access the same slave simultaneously. 9.9.1 supported transfers the arm926ej-s processor performs all ahb accesses as single word, bursts of four words, or bursts of eight words. any arm9ej-s core request that is not 1, 4, 8 word s in size is split into packets of these sizes. note that the atmel bus is ahb-lite protocol compliant, hence it does not support split and retry requests. table 8 gives an overview of the supported transfers and different kinds of transactions they are used for. 9.9.2 thumb instruction fetches all instructions fetches, regardless of the state of arm9ej-s core, are made as 32-bit accesses on the ahb. if the arm9ej-s is in thumb state, then two instructions can be fetched at a time. 9.9.3 address alignment the arm926ej-s biu performs address alignment checking and aligns ahb addresses to the necessary boundary. 16-bit accesses are aligned to halfword boundaries, and 32-bit accesses are aligned to word boundaries. table 9-7. supported transfers hburst[2:0] description single single transfer single transfer of word, half word, or byte: ? data write (ncnb, ncb, wt, or wb that has missed in dcache) ? data read (ncnb or ncb) ? nc instruction fetch (prefetched and non-prefetched) ? page table walk read incr4 four-word incrementing burst half-line cache write-back, instruction pr efetch, if enabled. four-word burst ncnb, ncb, wt, or wb write. incr8 eight-word incrementing burst full-line cache writ e-back, eight-word burst ncnb, ncb, wt, or wb write. wrap8 eight-word wrapping burst cache linefill
50 6438fCatarmC21-jun-10 at91sam9g45
51 6438fCatarmC21-jun-10 at91sam9g45 10. at91sam9g45 debug and test 10.1 description the at91sam9g45 fe atures a number of complementary debug and test c apabilities. a com- mon jtag/ice (in-circuit emulator) port is used for standard debugging functions, such as downloading code and single-stepping through programs. the debug unit provides a two-pin uart that can be used to upload an application into internal sram. it manages the interrupt handling of the internal commtx and commrx signals that trace the activity of the debug communication channel. a set of dedicated deb ug and test input/ou tput pins gives direct acce ss to these capabilities from a pc-based test environment. 10.2 embedded characteristics ? arm926 real-time in-circuit emulator C two real-time watchpoint units C two independent registers: debug control register and debug status register C test access port accessible through jtag protocol C debug communications channel ? debug unit Ctwo-pin uart C debug communication channel interrupt handling C chip id register ? ieee1149.1 jtag boundary-scan on all digital pins .
52 6438fCatarmC21-jun-10 at91sam9g45 10.3 block diagram figure 10-1. debug and test block diagram ice-rt arm9ej-s pdc dbgu pio drxd dtxd tms tck tdi jtagsel tst reset and test tap: test access port boundary port ice/jtag ta p arm926ej-s por rtck ntrst tdo
53 6438fCatarmC21-jun-10 at91sam9g45 10.4 application examples 10.4.1 debug environment figure 10-2 on page 53 shows a complete debug environment example. the ice/jtag inter- face is used for standard debugging functions, such as downloading code and single-stepping through the program. a software debugger running on a personal computer provides the user interface for configuring a trace port interf ace utilizing the ice/jtag interface. figure 10-2. application debug and trace environment example at91sam9g45-based application board ice/jtag interface host debugger pc ice/jtag connector at91sam9g45 terminal rs232 connector
54 6438fCatarmC21-jun-10 at91sam9g45 10.4.2 test environment figure 10-3 on page 54 shows a test environment example. test vectors are sent and inter- preted by the tester. in this example, the board in test is designed using a number of jtag- compliant devices. these devi ces can be connected to form a single scan chain. figure 10-3. application test environment example 10.5 debug and test pin description jtag interface at91sam9g45 test adaptor chip 2 chip n chip 1 ice/jtag tester at91sam9g45-based application board in test table 10-1. debug and test pin list pin name function type active level reset/test nrst microcontroller reset input/output low tst test mode select input high ice and jtag ntrst test reset signal input low tck test clock input tdi test data in input tdo test data out output tms test mode select input rtck returned test clock output jtagsel jtag selection input debug unit drxd debug receive data input dtxd debug transmit data output
55 6438fCatarmC21-jun-10 at91sam9g45 10.6 functional description 10.6.1 test pin one dedicated pin, tst, is used to define the device operating mode. the user must make sure that this pin is tied at low level to ensure normal operating conditions. other values associated with this pin are reserved for manufacturing test. 10.6.2 embeddedice the arm9ej-s embeddedice-rt ? is supported via the ice/jtag port. it is connected to a host computer via an ice interface. debug support is implemented using an arm9ej-s core embedded within the arm926ej-s. the internal state of the arm926ej-s is examined through an ice/jtag port which allows instructions to be serially inserted into the pipeline of the core without using the external data bus. therefore, when in debug state, a store-multiple (stm) can be inserted into the instruction pipeline. this exports the contents of the arm9ej-s registers. this data can be serially shifted out without affecting the rest of the system. there are two scan chains inside the arm9ej -s processor which support testing, debugging, and programming of the embeddedice-rt. the scan chains are controlled by the ice/jtag port. embeddedice mode is selected when jtagsel is low. it is not possible to switch directly between ice and jtag operations. a chip reset must be performed after jtagsel is changed. for further details on the embeddedice-rt, see the arm document: arm9ej-s technical reference manual (ddi 0222a). 10.6.3 jtag signal description tms is the test mode select input which controls the transitions of the test interface state machine. tdi is the test data input line which supplies the data to the jtag registers (boundary scan register, instruction register, or other data registers). tdo is the test data output line which is used to serially output the data from the jtag regis- ters to the equipment controlling the test. it carries the sampled values from the boundary scan chain (or other jtag registers) and propagates them to the next chip in the serial test circuit. ntrst (optional in ieee standard 1149.1) is a test-reset input which is mandatory in arm cores and used to reset the debug logic. on atmel arm926ej-s-based cores, ntrst is a power on reset output. it is asserted on power on. if necessary, the user can also reset the debug logic with the ntrst pin assertion during 2.5 mck periods. tck is the test clock input which enables the te st interface. tck is pulsed by the equipment controlling the test and not by the tested device. it can be pulsed at any frequency. note the maximum jtag clock rate on arm926ej-s cores is 1/6th the clock of the cpu. this gives 5.45 khz maximum initial jtag clock rate for an ar m9e running from the 32.768 khz slow clock. rtck is the return test clock. not an ieee standard 1149.1 signal added for a better clock handling by emulators. from some ice interface probes, this return signal can be used to syn- chronize the tck clock and take not care about the given ratio between the ice interface clock and system clock equal to 1/6th. this signal is only available in jtag ice mode and not in boundary scan mode.
56 6438fCatarmC21-jun-10 at91sam9g45 10.6.4 debug unit the debug unit provides a two-pin (dxrd a nd txrd) usart that can be used for several debug and trace purposes and offers an ideal means for in-situ programming solutions and debug monitor communication. moreover, the association with two peripheral data controller channels permits packet handling of these tasks with processor time reduced to a minimum. the debug unit also manages the interrupt handling of the commtx and commrx signals that come from the ice and that trace the activity of the debug communication channel.the debug unit allows blockage of access to the system through the ice interface. a specific register, the debug unit chip id register, gives information about the product version and its internal configuration. the at91sam9g45 debug unit chip id value is 0x819b 05a2 and the extended id is 0x00000004 on 32-bit width. for further details on the debug unit, see the debug unit section. 10.6.5 ieee 1149.1 jtag boundary scan ieee 1149.1 jtag boundary scan allows pin-level access independent of the device packaging technology. ieee 1149.1 jtag boundary scan is enabled when jtagsel is high. the sample, extest and bypass functions are implemented. in ic e debug mode, the ar m processor responds with a non-jtag ch ip id that identifi es the processo r to the ice system. this is not ieee 1149.1 jtag-compliant. it is not possible to switch directly between jtag and ice operations. a chip reset must be per- formed after jtagsel is changed. a boundary-scan descriptor language (bsdl) file is provided to set up test. 10.6.6 jid code register access: read-only ? version[31:28]: product version number set to 0x0. ? part number[27:12]: product part number product part number is 5b27 ? manufacturer identity[11:1] set to 0x01f. bit[0] required by ieee std. 1149.1. set to 0x1. jtag id code value is 05b2_703f. 31 30 29 28 27 26 25 24 version part number 23 22 21 20 19 18 17 16 part number 15 14 13 12 11 10 9 8 part number manufacturer identity 76543210 manufacturer identity 1
57 6438fCatarmC21-jun-10 at91sam9g45 11. boot strategies the system always boots at address 0x0. to ensure maximum boot possibilities the memory layout can be changed with two parameters. ? remap allows the user to layout the internal sram bank to 0x0 to ease the development. this is done by software once the system has boot. ? bms allows the user to layout to 0x0, when convenient, the rom or an external memory. this is done by hardware at reset. note: all the memory blocks can always be seen at their specified base addresses that are not concerned by these parameters. the at91sam9g45 manages a boot memory that depends on the level on the bms pin at reset. the internal memory area mapped between address 0x0 and 0x000f ffff is reserved to this effect. if bms is detected at 0, the boot memory is the memory connected on the chip select 0 of the external bus interface. ? boot on on-chip rc ? boot with the default configuration for the static memory controller, byte select mode, 16-bit data bus, read/write controlled by chip select, allows boot on 16-bit non-volatile memory. for optimization purpose, nothing else is do ne. to speed up the boot sequence user pro- grammed software should perform a complete configuration: ? enable the 32768 hz oscillator if best accuracy is needed ? program the pmc (main oscilla tor enable or bypass mode) ? program and start the pll ? reprogram the smc setup, cycle, hold, mode timi ngs registers for ebi cs0 to adapt them to the new clock ? switch the system clock to the new value if bms is detected at 1, the boot memory is the embedded rom and the boot program described below is executed. 11.1 boot program the boot program is contained in the embedded rom. it is also called: rom code or first level bootloader. at power on, if the bms pin is detected at 1, the boot memory is the embed- ded rom and the boot program is executed. the boot program consists of several steps. first, it performs device initialization. then it attempts to boot from external non volatile memories (nvm). and finally, if no valid program is found in nvm, it executes a monitor called sam-ba ? monitor.
58 6438fCatarmC21-jun-10 at91sam9g45 11.2 flow diagram the boot program implements the algorithm shown below in figure 11-1 . figure 11-1. boot program algorithm flow diagram sam-ba monitor co p y an d r u n i t in internal sram ye s device set up valid boot code found in one nvm no
59 6438fCatarmC21-jun-10 at91sam9g45 11.3 device initialization 11.3.1 clock at start up at boot start up, the processor clock (pck) and the master clock (mck) are found on the slow clock. the slow clock can be an external 32 khz cr ystal oscillator or the in ternal rc oscillator. by default the slow clock is the internal rc oscillato r. its frequency is not precise and is between 20 khz and 40 khz. its start up is much faster than an external 32 khz quartz. if a battery supplies the backup power and if the external 32 khz clock was previously started up and selected, the slow clock at boot is the external 32 khz quartz oscillator. refer to the slow clock crystal oscil- lator description in the clock generator section of the datasheet. 11.3.2 initialization sequence initialization follows the steps described below: 1. stack setup for arm supervisor mode. 2. main oscillator detection: (external crystal or external clock on xin). the main oscil- lator is disabled at startup (moscen = 0). first it is bypassed (oscbypass set at 1). then the mainrdy bit is polled. since this bit is raised, the main clock frequency field is analyzed (mainf). if the value is bigger than 16, an external clock connected on xin is detected. if not, an external quartz connected between xin and xout (whose fre- quency is unknown at this moment) is detected. 3. main oscillator enabling : if an external clock is connec ted on xin, the main oscillator does not need to be started. otherwise, the oscbypass bit is not set. the main oscil- lator is enabled (moscen = 1) with the maximum start-up time and the mosc bit is polled to wait for stabilization. 4. main oscillator selection : the master clock source is switched from slow clock to the main oscillator without prescaler. the pmc status regist er is polled to wait for mck ready. pck and mck are now the main oscillator clock. 5. c variable initialization: non zero-initialized data are initialized in ram (copy from rom to ram). zero-initialized data are set to 0 in ram. 6. plla initialization: plla is configured to allow communication on the usb link for the sam-ba monitor. its configuration depends on the main oscillato r source (external clock or crystal) and on its frequency.
60 6438fCatarmC21-jun-10 at91sam9g45 11.4 nvm boot 11.4.1 nvm bootloader program description figure 11-2. nvm bootloader program diagram en d valid code detection in nvm ye s copy the valid code from external nvm to internal sram. rest ore t he reset values for t he peripherals. perform the remap and set the pc to 0 to jump to the downloaded application initialize nvm nvm cont ains valid code ye s st a r t initialization ok ? rest ore t he reset values for the peripherals and jump to next boot solution no no
61 6438fCatarmC21-jun-10 at91sam9g45 figure 11-3. remap action after download completion the nvm bootloader program initializes the nvm. it initializes the required pio. it sets the right peripheral depending on the nvm and tries to access the memory. if the initialization fails, it restores the reset values for the pio and peripherals and then the next nvm bootloader program is executed. if the initialization is successful, the nvm bootloader program reads the beginning of the nvm and determines if the nvm contains valid code. if the nvm does not contain valid code, the nvm bootloader program restores the reset value for the peripherals and then the next nvm bootloader program is executed. if valid code is found, this code is loaded from nvm into internal sram and executed by branch- ing at address 0x0000_0000 after remap. this code may be the application code or a second- level bootloader. all the calls to functions are pc relative and do not use absolute addresses. 11.4.2 valid code detection there are two kinds of valid code detection . depending on the nvm bootloader, either one or both of them is used. 11.4.2.1 arm exception vectors check the nvm bootloader program reads and analyzes the first 28 bytes corresponding to the first seven arm exception vectors. except for the si xth vector, these bytes must implement the arm instructions for either branch or load pc with pc relative addressing. figure 11-4. ldr opcode rem a p internal rom internal sra m 0x0030_0000 0x0000_0000 internal rom 0x0040_0000 internal sram internal sra m 0x0030_000 0 0x0000_000 0 internal rom 0x0040_000 0 31 28 27 24 23 20 19 16 15 12 11 0 111001 i pu1w0 rn rd oset
62 6438fCatarmC21-jun-10 at91sam9g45 figure 11-5. b opcode unconditional instruction: 0xe for bits 31 to 28 load pc with pc relative addressing instruction: C rn = rd = pc = 0xf C i==0 (12-bit immediate value) C p==1 (pre-indexed) C u offset added (u==1) or subtracted (u==0) Cw==1 the sixth vector, at offset 0x14, contains the size of the image to download. the user must replace this vector with his/her own vector. this information is described below. figure 11-6. structure of the arm vector 6 the value has to be smaller than 60 kbytes. 60 kbytes is the maximum size for a valid code. this size is the internal sram size minus the stack size used by the rom code at the end of the internal sram. example an example of valid vectors follows: 00 ea000006 b 0x20 04 eafffffe b 0x04 08 ea00002f b _main 0c eafffffe b 0x0c 10 eafffffe b 0x10 14 00001234 b 0x14 <- code size = 4660 bytes < 60kb 18 eafffffe b 0x18 11.4.2.2 boot.bin file check the nvm bootloader program looks for a boot.bin file in the root directory of a fat12/16/32 for- matted nvm flash. 31 28 27 24 23 0 11101010 oset (24 bits) 31 0 size of t he code t o download in byt es
63 6438fCatarmC21-jun-10 at91sam9g45 11.4.3 nvm bootloader sequence figure 11-7. nvm bootloader sequence diagram 11.4.3.1 nand flash boot the nand flash bootloader program uses the ebi cs3. it uses both valid code detections. first it searches a boot.bin file. then it analyzes the arm exception vectors. the first block must be guaranteed by the manufacturer. there is no ecc check. after nand flash interface configuration, the manuf acturer id is read. if it is different from 0xff, the device id is read, else, the nand flash boot is aborted. the boot program contains a list of slc small block device id with their charac teristics (size, bus width, voltage) (see table 11-1 ). if the device id is not found in this list, the nand flash device is considered as an slc large block and its characteristics are obtained by reading the extended device id byte 3. spi flash boot ye s twi eeprom boot ye s nand flash boot copy from nand flash to sram run ye s nand flash bootloader no sd card boot copy from sd card to sram run ye s sd card bootloader no device setup no no sam-ba monitor copy from spi flash to sram copy from twi eeprom to sram spi flash bootloader twi eeprom bootloader run run
64 6438fCatarmC21-jun-10 at91sam9g45 supported nand flash devices the supported slc small block nand flash devices that are described below in table 11-1 . the nand flash boot also supports all the slc large block nand flash devices. 11.4.3.2 sd card boot the sd card bootloader uses mci0. it uses only one valid code detection. it searches a boot.bin file. supported sd card devices sd card boot supports all sd card memories compliant with sd memo ry card specification v2.0. this includes sdhc cards. table 11-1. supported slc small block nand flash device id size (mbytes) pagesize (bytes) blockssize (bytes) bus width voltag e (v) 0x6e 1 256 4096 8 5 0x64 2 256 4096 8 5 0x6b 4 512 8196 8 5 0xe8 1 256 4096 8 3.3 0xec 1 256 4096 8 3.3 0xea 2 256 4096 8 3.3 0xe3 4 512 8196 8 3.3 0xe5 4 512 8196 8 3.3 0xd6 8 512 8196 8 3.3 0xe6 8 512 8196 8 3.3 0x33 16 512 16384 8 1.8 0x73 16 512 16384 8 3.3 0x43 16 512 16384 16 1.8 0x53 16 512 16384 16 3.3 0x45 32 512 16384 16 1.8 0x55 32 512 16384 16 3.3 0x36 64 512 16384 8 1.8 0x76 64 512 16384 8 3.3 0x46 64 512 16384 16 1.8 0x56 64 512 16384 16 3.3 0x78 128 512 16384 8 1.8 0x79 128 512 16384 8 3.3 0x72 128 512 16384 16 1.8 0x74 128 512 16384 16 3.3
65 6438fCatarmC21-jun-10 at91sam9g45 11.4.3.3 spi flash boot two kinds of spi flash are supported, spi serial flash and spi dataflash. the spi flash bootloader tries to boot on spi0 chip select 0, first looking for spi serial flash, and then for spi dataflash. it uses only one valid code detection: analysis of arm exception vectors. the spi flash read is done thanks to a continuous read command from address 0x0. this command is 0xe8 for dataflash an d 0x0b for serial flash devices. supported dataflash devices the spi flash boot program supports all atmel dataflash devices. supported serial flash devices the spi flash boot program supp orts all serial flash devices. 11.4.3.4 twi eeprom boot the twi eeprom bootloader uses the twi0. it uses only one valid code detection. it analyzes the arm exception vectors. supported twi eeprom devices twi eeprom boot supports all i 2 c-compatible twi eeprom memories using 7 bits device address 0x50. 11.4.4 hardware and software constraints the nvm drivers use several pios in peripheral mode to communicate with devices. care must be taken when these pios are used by the app lication. the devices connected could be unin- tentionally driven at boot time, and electrical conflicts between output pins used by the nvm drivers and the connected devices may occur. to assure correct functionality, it is recommend ed to plug in critical devices to other pins not used by nvm. table 11-3 contains a list of pins that are driven during the boot program execution. these pins are driven during the boot sequence for a period of less than 1 second if no correct boot program is found. table 11-2. dataflash device device density page size (bytes) number of pages at45db011 1 mbit 264 512 at45db021 2 mbits 264 1024 at45db041 4 mbits 264 2048 at45db081 8 mbits 264 4096 at45db161 16 mbits 528 4096 at45db321 32 mbits 528 8192 at45db642 64 mbits 1056 8192
66 6438fCatarmC21-jun-10 at91sam9g45 before performing the jump to the application in internal sram, all the pios and peripherals used in the boot program are set to their reset state. 11.5 sam-ba monitor if no valid code has been found in nvm during the nvm bootloader sequence, the sam-ba monitor program is launched. the sam-ba monitor principle is to: C initialize dbgu and usb C check if usb device enumeration has occurred. C check if characters have been received on the dbgu. C once the communication interface is identified, the application runs in an infinite loop waiting for different commands as listed in table . table 11-3. pio driven during boot program execution nvm bootloader peripheral pin pio line nand ebi cs3 smc nandcs pioc14 ebi cs3 smc nand ale a21 ebi cs3 smc nand cle a22 ebi cs3 smc cmd/addr/data d[16:0] sd card mci0 mci0_ck pioa0 mci0 mci0_cd pioa1 mci0 mci0_d0 pioa2 mci0 mci0_d1 pioa3 mci0 mci0_d2 pioa4 mci0 mci0_d3 pioa5 spi flash spi0 mosi piob1 spi0 miso piob0 spi0 spck piob2 spi0 npcs0 piob3 twi0 eeprom twi0 twd0 pioa20 twi0 twck0 pioa21 sam-ba monitor dbgu drxd piob12 dbgu dtxd piob13
67 6438fCatarmC21-jun-10 at91sam9g45 figure 11-8. sam-ba monitor diagram 11.5.1 command list ? mode commands: C normal mode configures sam-ba monitor to send / receive data in binary format, C terminal mode configures sam-ba monitor to send / receive data in ascii format. ? write commands: write a byte ( o ), a halfword ( h ) or a word ( w ) to the target. C address : address in hexadecimal. C value : byte, halfword or word to write in hexadecimal. charact er(s) received on dbgu ? run monitor wait for command on the usb link run monitor wait for command on the dbgu link usb enumerat ion successful ? ye s ye s no no init dbgu and usb no valid code in nvm table 11-4. commands available through the sam-ba monitor command action argument(s) example n set normal mode no argument n # t set terminal mode no argument t # o write a byte address, value# o 200001,ca# o read a byte address,# o 200001,# h write a half word address, value# h 200002,cafe# h read a half word address,# h 200002,# w write a word address, value# w 200000,cafedeca# w read a word address,# w 200000,# s send a file address,# s 200000,# r receive a file address, nbofbytes# r 200000,1234# g go address# g 200200# v display version no argument v #
68 6438fCatarmC21-jun-10 at91sam9g45 C output : >. ? read commands: read a byte ( o ), a halfword ( h ) or a word ( w ) from the target. C address : address in hexadecimal C output : the byte, halfword or word read in hexadecimal following by > ? send a file ( s ): send a file to a specified address C address : address in hexadecimal C output : >. note: there is a time-out on this command which is reached when the prompt > appears before the end of the command execution. ? receive a file ( r ): receive data into a file from a specified address C address : address in hexadecimal C nbofbytes : number of bytes in hexadecimal to receive C output : > ?go ( g ): jump to a specified address and execute the code C address : address to jump in hexadecimal C output : >once returned from the program execution. if the executed program does not handle the link register at its entry and does not re turn, the prom pt will not be displayed. ? get version ( v ): return the boot program version C output : version, date and time of rom code followed by the prompt: >. 11.5.2 dbgu serial port communication is performed through the dbgu serial port initialized to 115200 baud, 8 bits of data, no parity, 1 stop bit. 11.5.2.1 supported external crystal/external clocks the sam-ba monitor supports a frequency of 12 mhz to allow dbgu communication for both external crystal and external clock. 11.5.2.2 xmodem protocol the send and receive file commands use the xmodem protocol to communicate. any terminal performing this protocol can be used to send th e application file to the target. the size of the binary file to send depends on the sram size embedded in the product. in all cases, the size of the binary file must be lower than the sram si ze because the xmodem protocol requires some sram memory in order to work. the xmodem protocol supported is the 128-byte l ength block. this protocol uses a two-charac- ter crc-16 to guarantee detection of a maximum bit error. xmodem protocol with crc is accurate provided both sender and receiver report successful transmission. each block of the transfer looks like: <255-blk #><--128 da ta bytes--> in which: C = 01 hex C = binary number, starts at 01, increments by 1, and wraps 0ffh to 00h (not to 01) C <255-blk #> = 1s complement of the blk#.
69 6438fCatarmC21-jun-10 at91sam9g45 C = 2 bytes crc16 figure 11-9 shows a transmission using this protocol. figure 11-9. xmodem transfer example 11.5.3 usb device port 11.5.3.1 supported external crystal / external clocks the only frequency supported by sam-ba moni tor to allow usb communication is a 12 mhz crystal or external clock. 11.5.3.2 usb class the device uses the usb communication device class (cdc) drivers to take advantage of the installed pc rs-232 software to talk over the usb. the cdc class is implemented in all releases of windows ? , from windows 98se ? to windows xp ? . the cdc document, available at www.usb.org , describes how to implement devices su ch as isdn modems and virtual com ports. the vendor id is atmels vendor id 0x03eb. the product id is 0x6124. these references are used by the host operating system to mount the correct driver. on windows systems, the inf files contain the correspondence between vendor id and product id. host device soh 01 fe data[128] crc crc c ack soh 02 fd data[128] crc crc ack soh 03 fc data[100] crc crc ack eot ack
70 6438fCatarmC21-jun-10 at91sam9g45 11.5.3.3 enumeration process the usb protocol is a master/slave protocol. the host starts the enumeration, sending requests to the device through the control endpoint. the device handles standard requests as defined in the usb specification. the device also handles some class requests defined in the cdc class. unhandled requests are stalled. 11.5.3.4 communication endpoints there are two communication endpoints and endpoint 0 is used for the enumeration process. endpoint 1 is a 64-byte bulk out endpoint and endpoint 2 is a 64-byte bulk in endpoint. sam- ba boot commands are sent by the host through endpoint 1. if required, the message is split by the host into several data payloads by the host driver. if the command requires a response, the host can send in transactions to pick up the response. table 11-5. handled standard requests request definition get_descriptor returns the current device configuration value. set_address sets the device address for all future device access. set_configuration sets the device configuration. get_configuration returns the curr ent device configuration value. get_status returns status for the specified recipient. set_feature used to set or enable a specific feature. clear_feature used to clear or disable a specific feature. table 11-6. handled class requests request definition set_line_coding configures dte rate, stop bits, parity and number of character bits. get_line_coding requests current dte rate, stop bits, parity and number of character bits. set_control_line_state rs-232 signal used to tell the dce device the dte device is now present.
71 6438fCatarmC21-jun-10 at91sam9g45 12. reset controller (rstc) 12.1 description the reset controller (rstc), based on power-on reset cells, handles all the resets of the sys- tem without any external components. it reports which reset occurred last. the reset controller also drives independently or simultaneously the external reset and the peripheral and processor resets. 12.2 embedded characteristics the reset controller is based on two power-on-reset cells, one on vddbu and one on vddcore. the reset controller is capable to return to the software the source of the last reset, either a general reset (vddbu rising), a wake-up reset (vddcore rising), a software reset, a user reset or a watchdog reset. the reset controller controls t he internal resets of the system and the nrst pin. the nrst pin is bidirectional. it is handled by the on-chip re set controller and can be driven low to provide a reset signal to the external components or assert ed low externally to reset the microcontroller. it will reset the core and the peripherals except t he backup region. there is no constraint on the length of the reset pulse and the reset controller can guarantee a minimum pulse length. the nrst pin integrates a permanent pull-up resistor to vddiop0 of about 100 kohms. the configuration of the reset controller is saved as supplied on vddbu. 12.3 block diagram figure 12-1. reset controller block diagram nrst startup counter proc_nreset wd_fault periph_nreset backup_neset slck reset state manager reset controller rstc_irq nrst manager exter_nreset nrst_out main supply por wdrproc user_reset backup supply por
72 6438fCatarmC21-jun-10 at91sam9g45 12.4 functional description 12.4.1 reset controller overview the reset controller is made up of an nrst manager, a startup counter and a reset state manager. it runs at slow clock and generates the following reset signals: ? proc_nreset: processor reset line. it also resets the watchdog timer. ? backup_nreset: affects all the peripherals powered by vddbu. ? periph_nreset: affects the whole set of embedded peripherals. ? nrst_out: drives the nrst pin. these reset signals are asserted by the reset cont roller, either on external events or on soft- ware action. the reset state manager controls the generation of reset signals and provides a signal to the nrst manager when an assertion of the nrst pin is required. the nrst manager shapes the nrst assertion du ring a programmable ti me, thus controlling external device resets. the startup counter waits for the complete crystal oscillator startu p. the wait de lay is given by the crystal oscillator startup time maximum value that can be foun d in the section crystal oscil- lator characteristics in the electrical characteristics section of the product documentation. the reset controller mode register (rstc_mr), allowing the configuration of the reset con- troller, is powered with vddbu, so that its configuration is saved as long as vddbu is on. 12.4.2 nrst manager the nrst manager samples the nrst input pin and drives this pin low when required by the reset state manager. figure 12-2 shows the block diagram of the nrst manager. figure 12-2. nrst manager 12.4.2.1 nrst signal or interrupt the nrst manager samples the nrst pin at slow clock speed. when the line is detected low, a user reset is reported to the reset state manager. however, the nrst manager can be programmed to not trigger a reset when an assertion of nrst occurs. writing the bit ursten at 0 in rstc_mr disables the user reset trigger. external reset timer ursts ursten erstl exter_nreset urstien rstc_mr rstc_mr rstc_mr rstc_sr nrstl nrst_out nrst rstc_irq other interrupt sources user_reset
73 6438fCatarmC21-jun-10 at91sam9g45 the level of the pin nrst can be read at any ti me in the bit nrstl (nrst level) in rstc_sr. as soon as the pin nrst is asserted, the bit ur sts in rstc_sr is set. this bit clears only when rstc_sr is read. the reset controller can also be programmed to generate an interrupt instead of generating a reset. to do so, the bit urstien in rstc_mr must be written at 1. 12.4.2.2 nrst external reset control the reset state manager asserts the signal ext_nreset to assert the nrst pin. when this occurs, the nrst_out signal is driven low by the nrst manager for a time programmed by the field erstl in rstc_mr. this assertion duration, named externa l_reset_length, lasts 2 (erstl+1) slow clock cycles. this gives the approximate duration of an assertion between 60 s and 2 seconds. note that erstl at 0 defines a two-cycle duration for the nrst pulse. this feature allows the reset controller to shape the nrst pin level, and thus to guarantee that the nrst line is driven low for a time compliant with potential external devices connected on the system reset. as the field is within rstc_mr, which is backed -up, this field can be used to shape the system power-up reset for devi ces requiring a longer startup time than the slow clock oscillator. 12.4.3 bms sampling the product matrix manages a boot memory that depends on the level on the bms pin at reset. the bms signal is sampled three slow clock cycl es after the core power-on-reset output rising edge. figure 12-3. bms sampling 12.4.4 reset states the reset state manager handles the different reset sources and generates the internal reset signals. it reports the reset status in the field rsttyp of the status register (rstc_sr). the update of the field rsttyp is performed when the processor reset is released. 12.4.4.1 general reset a general reset occurs when vddbu and vddcore are powered on. the backup supply por cell output rises and is filtered with a startup counter, which operates at slow clock. the pur- pose of this counter is to make sure the slow clock oscillator is stable before starting up the slck core supply por output bms sampling delay = 3 cycles bms signal proc_nreset xxx h or l
74 6438fCatarmC21-jun-10 at91sam9g45 device. the length of startup ti me is hardcoded to comply with the slow clock oscillator startup time. after this time, the processor clock is released at slow clock and all the other signals remain valid for 3 cycles for proper processor and logic reset. then, all the reset signals are released and the field rsttyp in rstc_sr reports a general reset. as the rstc_mr is reset, the nrst line rises 2 cycles after the backup_nreset, as erstl defaults at value 0x0. when vddbu is detected low by the backup suppl y por cell, all resets signals are immedi- ately asserted, even if the main supply por cell does not report a main supply shutdown. vddbu only activates the backup_nreset signal. the backup_nreset must be released so that any other reset can be generated by vddcore (main supply por output). figure 12-4 shows how the general reset affects the reset signals. figure 12-4. general reset state slck periph_nreset proc_nreset backup supply por output nrst (nrst_out) external reset length = 2 cycles startup time mck processor startup = 3 cycles backup_nreset any freq. rsttyp xxx 0x0 = general reset xxx main supply por output bms sampling
75 6438fCatarmC21-jun-10 at91sam9g45 12.4.4.2 wake-up reset the wake-up reset occurs when the main supply is down. when the main supply por output is active, all the reset signals are asserted except backup_nreset. when the main supply pow- ers up, the por output is resynchronized on slow clock. the processor clock is then re-enabled during 3 slow clock cycles, depending on the requirements of the arm processor. at the end of this delay, the processor and other reset signals rise. the field rsttyp in rstc_sr is updated to report a wake-up reset. the nrst_out remains asserted for ext ernal_reset_length cycles. as rstc_mr is backed-up, the programmed number of cycles is applicable. when the main supply is detected falling, the re set signals are immediately asserted. this tran- sition is synchronous with the output of the main supply por. figure 12-5. wake-up state 12.4.4.3 user reset the user reset is entered when a low level is detected on the nrst pin and the bit ursten in rstc_mr is at 1. the nrst inpu t signal is resynchronized with slck to insure proper behav- ior of the system. the user reset is entered as soon as a low level is detected on nrst. the processor reset and the peripheral reset are asserted. the user reset is left when nrst rises, after a two-cycle resynchronization time and a 3-cycle processor startup. the processor clock is re-enabled as soon as nrst is confirmed high. slck periph_nreset proc_nreset main supply por output nrst (nrst_out) external reset length = 4 cycles (erstl = 1) mck processor startup = 3 cycles backup_nreset any freq. resynch. 2 cycles rsttyp xxx 0x1 = wakeup reset xxx
76 6438fCatarmC21-jun-10 at91sam9g45 when the processor reset signal is released, the rsttyp field of the status register (rstc_sr) is loaded with the value 0x4, indicating a user reset. the nrst manager guarantees that the nrst line is asserted for external_reset_length slow clock cycles, as programmed in the field erstl. how- ever, if nrst does not rise after extern al_reset_length because it is driven low externally, the internal reset lines remain asserted until nrst actually rises. figure 12-6. user reset state 12.4.4.4 software reset the reset controller offers several commands used to assert the different reset signals. these commands are performed by writing the control register (rstc_cr) with the following bits at 1: ? procrst: writing procrst at 1 resets the processor and the watchdog timer. ? perrst: writing perrst at 1 resets all the embedded peripherals, including the memory system, and, in particular, the remap command. the peripheral reset is generally used for debug purposes. except for debug purposes, perrst must always be used in conjunction with procrst (perrst and procrst set both at 1 simultaneously.) ? extrst: writing extrst at 1 asserts low the nrst pin during a time defined by the field erstl in the mode register (rstc_mr). the software reset is entered if at least one of these bits is set by the software. all these com- mands can be performed independently or simultaneously. the software reset lasts 3 slow clock cycles. slck periph_nreset proc_nreset nrst nrst (nrst_out) >= external reset length mck processor startup = 3 cycles any freq. resynch. 2 cycles rsttyp any xxx resynch. 2 cycles 0x4 = user reset
77 6438fCatarmC21-jun-10 at91sam9g45 the internal reset signals are asserted as soon as the register write is performed. this is detected on the master clock (mck). they are released when the software reset is left, i.e.; syn- chronously to slck. if extrst is set, the nrst_out signal is asserted depending on the programming of the field erstl. however, the result ing falling edge on nrst does not lead to a user reset. if and only if the procrst bit is set, the reset controller reports the software status in the field rsttyp of the status register (rstc_sr). other software resets are not reported in rsttyp. as soon as a software operation is detected, the bit srcmp (software reset command in prog- ress) is set in the status register (rstc_sr). it is cleared as soon as the software reset is left. no other software reset can be performed while the srcmp bit is set, and writing any value in rstc_cr has no effect. figure 12-7. software reset 12.4.4.5 watchdog reset the watchdog reset is entered when a watchdog fault occurs. this state lasts 3 slow clock cycles. when in watchdog reset, assertion of t he reset signals depends on the wdrproc bit in wdt_mr: ? if wdrproc is 0, the processor reset and the peripheral reset are asserted. the nrst line is also asserted, depending on the programming of the field erstl. however, the resulting low level on nrst does not result in a user reset state. slck periph_nreset if perrst=1 proc_nreset if procrst=1 write rstc_cr nrst (nrst_out) if extrst=1 external reset length 8 cycles (erstl=2) mck processor startup = 3 cycles any freq. rsttyp any xxx 0x3 = software reset resynch. 1 cycle srcmp in rstc_sr
78 6438fCatarmC21-jun-10 at91sam9g45 ? if wdrproc = 1, only the processor reset is asserted. the watchdog timer is reset by the proc_nreset si gnal. as the watchdog fault always causes a processor reset if wdrsten is set, the watc hdog timer is always reset after a watchdog reset, and the watchdog is enabled by default and with a period set to a maximum. when the wdrsten in wdt_mr bit is reset, the watchdog fault has no impact on the reset controller. figure 12-8. watchdog reset 12.4.5 reset state priorities the reset state manager manages the following priorities between the different reset sources, given in descending order: ? backup reset ? wake-up reset ? watchdog reset ? software reset ? user reset particular cases are listed below: ? when in user reset: C a watchdog event is impossible because the watchdog timer is being reset by the proc_nreset signal. C a software reset is impossible, since the processor reset is being activated. ? when in software reset: C a watchdog event has priority over the current state. C the nrst has no effect. only if wdrproc = 0 slck periph_nreset proc_nreset wd_fault nrst (nrst_out) external reset length 8 cycles (erstl=2) mck processor startup = 3 cycles any freq. rsttyp any xxx 0x2 = watchdog reset
79 6438fCatarmC21-jun-10 at91sam9g45 ? when in watchdog reset: C the processor reset is active and so a software reset cannot be programmed. C a user reset cannot be entered. 12.4.6 reset controller status register the reset controller status register (rstc_sr) provides several status fields: ? rsttyp field: this field gives the type of the last reset, as explained in previous sections. ? srcmp bit: this field indicates that a software reset command is in progress and that no further software reset should be performed until the end of the current one. this bit is automatically cleared at the end of the current software reset. ? nrstl bit: the nrstl bit of the status register gives the level of the nrst pin sampled on each mck rising edge. ? ursts bit: a high-to-low transition of the nrst pin sets the ursts bit of the rstc_sr register. this transition is also detected on the master clock (mck) rising edge (see figure 12-9 ). if the user reset is disabled (ursten = 0) and if the interruption is enabled by the urstien bit in the rstc_mr register, the ursts bit triggers an interrupt. reading the rstc_sr status register resets the ursts bit and clears the interrupt. figure 12-9. reset controller status and interrupt mck nrst nrstl 2 cycle resynchronization 2 cycle resynchronization ursts read rstc_sr peripheral access rstc_irq if (ursten = 0) and (urstien = 1)
80 6438fCatarmC21-jun-10 at91sam9g45 12.5 reset controller (rstc) user interface note: 1. the reset value of rstc_sr either reports a general reset or a wake-up reset depending on last rising power supply. table 12-1. register mapping offset register name access reset backup reset 0x00 control register rstc_cr write-only - 0x04 status register rstc_sr read-only 0x0000_0001 0x0000_0000 0x08 mode register rstc_mr read-write - 0x0000_0001
81 6438fCatarmC21-jun-10 at91sam9g45 12.5.1 reset controller control register name: rstc_cr address: 0xfffffd00 access type: write-only ? procrst: processor reset 0 = no effect. 1 = if key is correct, resets the processor. ? perrst: peripheral reset 0 = no effect. 1 = if key is correct, resets the peripherals. ? extrst: external reset 0 = no effect. 1 = if key is correct, asserts the nrst pin. ?key: password should be written at value 0xa5. writing any other value in this field aborts the write operation. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCC C 76543210 CCCCextrstperrstCprocrst
82 6438fCatarmC21-jun-10 at91sam9g45 12.5.2 reset controller status register name: rstc_sr address: 0xfffffd04 access type: read-only ? ursts: user reset status 0 = no high-to-low edge on nrst happened since the last read of rstc_sr. 1 = at least one high-to-low transition of nrst has been detected since the last read of rstc_sr. ? rsttyp: reset type reports the cause of the last processor reset. r eading this rstc_sr does not reset this field. ? nrstl: nrst pin level registers the nrst pin level at master clock (mck). ? srcmp: software reset command in progress 0 = no software command is being performed by the reset controller. the reset controller is ready for a software command. 1 = a software reset command is being performed by the reset controller. the reset controller is busy. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCsrcmpnrstl 15 14 13 12 11 10 9 8 CCCCC rsttyp 76543210 CCCCCCCursts rsttyp reset type comments 0 0 0 general reset both vddcore and vddbu rising 0 0 1 wake up reset vddcore rising 0 1 0 watchdog reset watchdog fault occurred 0 1 1 software reset processor re set required by the software 1 0 0 user reset nrst pin detected low
83 6438fCatarmC21-jun-10 at91sam9g45 12.5.3 reset controller mode register name: rstc_mr address: 0xfffffd08 access type: read-write ? ursten: user reset enable 0 = the detection of a low level on the pin nrst does not generate a user reset. 1 = the detection of a low level on the pin nrst triggers a user reset. ? urstien: user reset interrupt enable 0 = usrts bit in rstc_sr at 1 has no effect on rstc_irq. 1 = usrts bit in rstc_sr at 1 asserts rstc_irq if ursten = 0. ? erstl: external reset length this field defines the external reset length. the external reset is asserted during a time of 2 (erstl+1) slow clock cycles. this allows assertion duration to be programmed between 60 s and 2 seconds. ?key: password should be written at value 0xa5. writing any other value in this field aborts the write operation. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 CCCCCCC 15 14 13 12 11 10 9 8 CCCC erstl 76543210 C C urstien C C C ursten
84 6438fCatarmC21-jun-10 at91sam9g45
85 6438fCatarmC21-jun-10 at91sam9g45 13. real-time timer (rtt) 13.1 description the real-time timer is built around a 32-bit coun ter and used to count elapsed seconds. it gen- erates a periodic interrupt and/or triggers an alarm on a programmed value. 13.2 embedded characteristics ? real-time timer, allowing backup of time with different accuracies C 32-bit free-running back-up counter C integrates a 16-bit programmable prescaler running on slow clock C alarm register capable to generate a wake-up of the system through the shut down controller 13.3 block diagram figure 13-1. real-time timer 13.4 functional description the real-time timer is used to count elapsed seconds. it is built around a 32-bit counter fed by slow clock divided by a programmable 16-bit va lue. the value can be programmed in the field rtpres of the real-time mode register (rtt_mr). programming rtpres at 0x00008000 corresponds to feeding the real-time counter with a 1 hz signal (if the slow clock is 32.768 khz). the 32-bit counter can count up to 2 32 seconds, corre- sponding to more than 136 years, then roll over to 0. slck rtpres rttinc alms 16-bit divider 32-bit counter almv = crtv rtt_mr rtt_vr rtt_ar rtt_sr rttincien rtt_mr 0 10 almien rtt_int rtt_mr set set rtt_sr read rtt_sr reset reset rtt_mr reload rtt_alarm rttrst rtt_mr rttrst
86 6438fCatarmC21-jun-10 at91sam9g45 the real-time timer can also be used as a free -running timer with a lower time-base. the best accuracy is achieved by writing rtpres to 3. programming rtpres to 1 or 2 is possible, but may result in losing status events because the st atus register is clear ed two slow clock cycles after read. thus if the rtt is configured to trigger an interrupt, the interrupt occurs during 2 slow clock cycles after reading rtt_sr. to prevent se veral executions of the interrupt handler, the interrupt must be disabled in the interrupt ha ndler and re-enabled when the status register is clear. the real-time timer value (crtv) can be read at any time in the register rtt_vr (real-time value register). as this value can be updated asynchronously from the master clock, it is advis- able to read this register twice at the same value to improve accuracy of the returned value. the current value of the counter is compared with the value written in the alarm register rtt_ar (real-time alarm register). if the counter value matches the alarm, the bit alms in rtt_sr is set. the alarm register is set to its maximum value, corresponding to 0xffff_ffff, after a reset. the bit rttinc in rtt_sr is set each time the real-time timer counter is incremented. this bit can be used to start a periodic interrupt, the period being one second when the rtpres is pro- grammed with 0x8000 and slow clock equal to 32.768 hz. reading the rtt_sr status register resets the rttinc and alms fields. writing the bit rttrst in rtt_mr immediately re loads and restarts the clock divider with the new programmed value. this also resets the 32-bit counter. note: because of the asynchronism between the slow clock (sclk) and the system clock (mck): 1) the restart of the counter and the reset of the rtt_vr current value register is effective only 2 slow clock cycles after the write of th e rttrst bit in the rtt_mr register. 2) the status register fl ags reset is taken into account only 2 sl ow clock cycles after the read of the rtt_sr (status register).
87 6438fCatarmC21-jun-10 at91sam9g45 figure 13-2. rtt counting pre s c a ler almv almv-1 0 almv+1 0 rtpre s - 1 rtt apb cycle re a d rtt_ s r alm s (rtt_ s r) apb interf a ce s clk rttinc (rtt_ s r) almv+2 almv+ 3 ... apb cycle
88 6438fCatarmC21-jun-10 at91sam9g45 13.5 real-time timer (rtt) user interface table 13-1. register mapping offset register name access reset 0x00 mode register rtt_mr read-write 0x0000_8000 0x04 alarm register rtt_ar read-write 0xffff_ffff 0x08 value register rtt_vr read-only 0x0000_0000 0x0c status register rtt_sr read-only 0x0000_0000
89 6438fCatarmC21-jun-10 at91sam9g45 13.5.1 real-time timer mode register register name: rtt_mr address: 0xfffffd20 access type: read/write ? rtpres: real-time timer prescaler value defines the number of slck periods required to increment the real-time timer. rtpres is defined as follows: rtpres = 0: the prescaler period is equal to 2 16 . rtpres 0: the prescaler period is equal to rtpres. ? almien: alarm interrupt enable 0 = the bit alms in rtt_sr has no effect on interrupt. 1 = the bit alms in rtt_sr asserts interrupt. ? rttincien: real-time timer increment interrupt enable 0 = the bit rttinc in rtt_sr has no effect on interrupt. 1 = the bit rttinc in r tt_sr asserts interrupt. ? rttrst: real-time timer restart 1 = reloads and restarts the clock divider with the new programmed value. this also resets the 32-bit counter. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCrttrstrttincienalmien 15 14 13 12 11 10 9 8 rtpres 76543210 rtpres
90 6438fCatarmC21-jun-10 at91sam9g45 13.5.2 real-time timer alarm register register name: rtt_ar address: 0xfffffd24 access type: read/write ? almv: alarm value defines the alarm value (almv+1) compared with the real-time timer. 13.5.3 real-time timer value register register name: rtt_vr address: 0xfffffd28 access type: read-only ? crtv: current real-time value returns the current value of the real-time timer. 31 30 29 28 27 26 25 24 almv 23 22 21 20 19 18 17 16 almv 15 14 13 12 11 10 9 8 almv 76543210 almv 31 30 29 28 27 26 25 24 crtv 23 22 21 20 19 18 17 16 crtv 15 14 13 12 11 10 9 8 crtv 76543210 crtv
91 6438fCatarmC21-jun-10 at91sam9g45 13.5.4 real-time timer status register register name: rtt_sr address: 0xfffffd2c access type: read-only ? alms: real-time alarm status 0 = the real-time alarm has not occurred since the last read of rtt_sr. 1 = the real-time alarm occurred since the last read of rtt_sr. ? rttinc: real-time timer increment 0 = the real-time timer has not been incremented since the last read of the rtt_sr. 1 = the real-time timer has been incremented since the last read of the rtt_sr. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCrttincalms
92 6438fCatarmC21-jun-10 at91sam9g45
93 6438fCatarmC21-jun-10 at91sam9g45 14. real-time clock (rtc) 14.1 description the real-time clock (rtc) peripheral is de signed for very low power consumption. it combines a complete time-of-day clock with alarm and a two-hundred-year gregorian calen- dar, complemented by a programmable periodic interrupt. the alarm and calendar registers are accessed by a 32-bit data bus. the time and calendar values are coded in binary-coded decimal (bcd) format. the time format can be 24-hour mode or 12-hour mode with an am/pm indicator. updating time and calendar fields and configuri ng the alarm fields are performed by a parallel capture on the 32-bit data bus. an entry control is performed to avoid loading registers with incompatible bcd format data or with an incompatible date according to the current month/year/century. 14.2 embedded characteristics ? low power consumption ? full asynchronous design ? two hundred year calendar ? programmable periodic interrupt ? alarm and update parallel load ? control of alarm and update time/calendar data in 14.3 block diagram figure 14-1. rtc block diagram bus interface 32768 divider time crystal oscillator: slck bus interface date rtc interrupt entry control interrupt control
94 6438fCatarmC21-jun-10 at91sam9g45 14.4 product dependencies 14.4.1 power management the real-time clock is cont inuously clocked at 32768 hz. the power management controller has no effect on rtc behavior. 14.4.2 interrupt the rtc interrupt is connected to interrupt source 1 (irq1) of the advanced interrupt controller. this interrupt line is due to th e or-wiring of the system periphera l interrupt lines (system timer, real time clock, power management controller, memory controller, etc.). when a system interrupt occurs, the service routi ne must first determine the cause of the interrupt. this is done by reading the status registers of the above system peripherals successively. 14.5 functional description the rtc provides a full binary-coded decimal (b cd) clock that includes century (19/20), year (with leap years), month, date, day, hours, minutes and seconds. the valid year range is 1900 to 2099, a two-hundred-year gregorian calendar achieving full y2k compliance. the rtc can operate in 24-hour mode or in 12-hour mode with an am/pm indicator. corrections for leap years are included (all years di visible by 4 being leap years, including year 2000). this is correct up to the year 2099. after hardware reset, the calendar is initialized to thursday, january 1, 1998. 14.5.1 reference clock the reference clock is slow clock (slck). it can be driven internally or by an external 32.768 khz crystal. during low power modes of the processor (idle mode), the oscillator runs and power consump- tion is critical. the crystal selection has to ta ke into account the current consumption for power saving and the frequency drift due to temperature effect on the circuit for time accuracy. 14.5.2 timing the rtc is updated in real time at one-second intervals in normal mode for the counters of sec- onds, at one-minute intervals for the counter of minutes and so on. due to the asynchronous operation of the rtc with respect to the rest of the chip, to be certain that the value read in the rtc registers (century, year, month, date, day, hours, minutes, sec- onds) are valid and stable, it is necessary to read these registers twice. if the data is the same both times, then it is valid. therefore, a minimu m of two and a maximum of three accesses are required. 14.5.3 alarm the rtc has five programmable fields: month, date, hours, minutes and seconds. each of these fields can be enabled or disabled to match the alarm condition: ? if all the fields are enabled, an alarm flag is generated (the corresponding flag is asserted and an interrupt generated if enabled) at a given month, date, hour/minute/second. ? if only the seconds field is enabled, then an alarm is generated every minute.
95 6438fCatarmC21-jun-10 at91sam9g45 depending on the co mbination of fields enabled, a large number of possibilit ies are available to the user ranging from minutes to 365/366 days. 14.5.4 error checking verification on user interface data is performed when accessing the century, year, month, date, day, hours, minutes, seconds and alarms. a chec k is performed on illegal bcd entries such as illegal date of the month with regard to the year and century configured. if one of the time fields is not correct, the data is not loaded into the register/counter and a flag is set in the validity register. the user can not reset this flag. it is reset as soon as an acceptable value is programmed. this avoids any further si de effects in the hardware. the same procedure is done for the alarm. the following checks are performed: 1. century (check if it is in range 19 - 20) 2. year (bcd entry check) 3. date (check range 01 - 31) 4. month (check if it is in bcd range 01 - 12, check validity regarding date) 5. day (check range 1 - 7) 6. hour (bcd checks: in 24-hour mode, check range 00 - 23 and check that am/pm flag is not set if rtc is set in 24-hour mode; in 12-hour mode check range 01 - 12) 7. minute (check bcd and range 00 - 59) 8. second (check bcd and range 00 - 59) note: if the 12-hour mode is selected by means of the rtc_mode register, a 12-hour value can be pro- grammed and the returned value on rtc_time will be the corresponding 24-hour value. the entry control checks the value of the am/pm indicato r (bit 22 of rtc_time register) to determine the range to be checked. 14.5.5 updating time/calendar to update any of the time/calendar fields, the user must first stop the rtc by setting the corre- sponding field in the control register. bit updtim must be set to update time fields (hour, minute, second) and bit updcal must be set to update calendar fields (century, year, month, date, day). then the user must poll or wait for the interrupt (if enabled) of bit ackupd in the status regis- ter. once the bit reads 1, it is mandatory to clear this flag by writing the corresponding bit in rtc_sccr. the user can now write to the appropriate time and calendar register. once the update is finished, the user must reset (0) updtim and/or updcal in the control when entering programming mode of the calendar fields, the time fields remain enabled. when entering the programming mode of the time fields, both time and calendar fields are stopped. this is due to the location of the calendar logi c circuity (downstream for low-power consider- ations). it is highly recommended to prepare all the fields to be updated before entering programming mode. in successive update operations, the user must wait at least one second after resetting the updtim/updcal bit in the rtc_cr (control register) before setting these bits again. this is done by waiting for the se c flag in the status register before setting updtim/updcal bit. after resetting updtim/updcal, the sec flag must also be cleared.
96 6438fCatarmC21-jun-10 at91sam9g45 figure 14-2. update sequence prepare time or calendar fields set updtim and/or updcal bit(s) in rtc_cr read rtc_sr ackupd = 1 ? clear ackupd bit in rtc_sccr update time andor calendar values in rtc_timr/rtc_calr clear updtim and/or updcal bit in rtc_cr no ye s begin end polling or irq (if enabled)
97 6438fCatarmC21-jun-10 at91sam9g45 14.6 reset controller (rtc) user interface table 14-1. register mapping offset register name access reset 0x00 control register rtc_cr read-write 0x0 0x04 mode register rtc_mr read-write 0x0 0x08 time register rtc_timr read-write 0x0 0x0c calendar register rtc_calr read-write 0x01819819 0x10 time alarm register rtc_timalr read-write 0x0 0x14 calendar alarm register rtc_calalr read-write 0x01010000 0x18 status register rtc_sr read-only 0x0 0x1c status clear command r egister rtc_sccr write-only --- 0x20 interrupt enable register rtc_ier write-only --- 0x24 interrupt disable regi ster rtc_idr write-only --- 0x28 interrupt mask register rtc_imr read-only 0x0 0x2c valid entry register rtc_ver read-only 0x0
98 6438fCatarmC21-jun-10 at91sam9g45 14.6.1 rtc control register name: rtc_cr address: 0xfffffdb0 access type: read-write ? updtim: update request time register 0 = no effect. 1 = stops the rtc time counting. time counting consists of second, minute and hour counters. time counters can be programmed once this bit is set and acknowledged by the bit ackupd of the status register. ? updcal: update request calendar register 0 = no effect. 1 = stops the rtc calendar counting. calendar counting consists of day, date, month, year and century counters. calendar counters can be programmed once this bit is set. ? timevsel: time ev ent selection the event that generates the flag timev in rtc_sr (status register) depends on the value of timevsel. 0 = minute change. 1 = hour change. 2 = every day at midnight. 3 = every day at noon. ? calevsel: calendar event selection the event that ge nerates the flag calev in rtc_sr depends on the value of calevsel. 0 = week change (every monday at time 00:00:00). 1 = month change (every 01 of each month at time 00:00:00). 2, 3 = year change (every january 1 at time 00:00:00). 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCC cal evsel 15 14 13 12 11 10 9 8 CCCCCC timevsel 76543210 CCCCCCupdcalupdtim
99 6438fCatarmC21-jun-10 at91sam9g45 14.6.2 rtc mode register name: rtc_mr address: 0xfffffdb4 access type: read-write ? hrmod: 12-/24-hour mode 0 = 24-hour mode is selected. 1 = 12-hour mode is selected. all non-significant bits read zero. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCChrmod
100 6438fCatarmC21-jun-10 at91sam9g45 14.6.3 rtc time register name: rtc_timr address: 0xfffffdb8 access type: read-write ? sec: current second the range that can be set is 0 - 59 (bcd). the lowest four bits encode the units. the higher bits encode the tens. ? min: current minute the range that can be set is 0 - 59 (bcd). the lowest four bits encode the units. the higher bits encode the tens. ? hour: current hour the range that can be set is 1 - 12 (bcd) in 12-hour mode or 0 - 23 (bcd) in 24-hour mode. ? ampm: ante meridiem post meridiem indicator this bit is the am/pm in dicator in 12-hour mode. 0 = am. 1 = pm. all non-significant bits read zero. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 Campm hour 15 14 13 12 11 10 9 8 Cmin 76543210 Csec
101 6438fCatarmC21-jun-10 at91sam9g45 14.6.4 rtc calendar register name: rtc_calr address: 0xfffffdbc access type: read-write ? cent: current century the range that can be set is 19 - 20 (bcd). the lowest four bits encode the units. the higher bits encode the tens. ? year: current year the range that can be set is 00 - 99 (bcd). the lowest four bits encode the units. the higher bits encode the tens. ? month: current month the range that can be set is 01 - 12 (bcd). the lowest four bits encode the units. the higher bits encode the tens. ? day: current day in current week the range that can be set is 1 - 7 (bcd). the coding of the number (which number represents which day) is user-defined as it has no effect on the date counter. ? date: current day in current month the range that can be set is 01 - 31 (bcd). the lowest four bits encode the units. the higher bits encode the tens. all non-significant bits read zero. 31 30 29 28 27 26 25 24 CC date 23 22 21 20 19 18 17 16 day month 15 14 13 12 11 10 9 8 year 76543210 Ccent
102 6438fCatarmC21-jun-10 at91sam9g45 14.6.5 rtc time alarm register name: rtc_timalr address: 0xfffffdc0 access type: read-write ? sec: second alarm this field is the alarm field corresponding to the bcd-coded second counter. ? secen: second alarm enable 0 = the second-matching alarm is disabled. 1 = the second-matching alarm is enabled. ? min: minute alarm this field is the alarm field corresponding to the bcd-coded minute counter. ? minen: minute alarm enable 0 = the minute-matching alarm is disabled. 1 = the minute-matching alarm is enabled. ? hour: hour alarm this field is the alarm field corresponding to the bcd-coded hour counter. ? ampm: am/pm indicator this field is the alarm field corresponding to the bcd-coded hour counter. ? houren: hour alarm enable 0 = the hour-matching alarm is disabled. 1 = the hour-matching alarm is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 houren ampm hour 15 14 13 12 11 10 9 8 minen min 76543210 secen sec
103 6438fCatarmC21-jun-10 at91sam9g45 14.6.6 rtc calendar alarm register name: rtc_calalr address: 0xfffffdc4 access type: read-write ? month: month alarm this field is the alarm field corresponding to the bcd-coded month counter. ? mthen: month alarm enable 0 = the month-matching alarm is disabled. 1 = the month-matching alarm is enabled. ?date: date alarm this field is the alarm field corresponding to the bcd-coded date counter. ? dateen: date alarm enable 0 = the date-matching alarm is disabled. 1 = the date-matching alarm is enabled. 31 30 29 28 27 26 25 24 dateen C date 23 22 21 20 19 18 17 16 mthen C C month 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCC
104 6438fCatarmC21-jun-10 at91sam9g45 14.6.7 rtc status register name: rtc_sr address: 0xfffffdc8 access type: read-only ? ackupd: acknowledge for update 0 = time and calendar registers cannot be updated. 1 = time and calendar registers can be updated. ? alarm: alarm flag 0 = no alarm matching condition occurred. 1 = an alarm matching condition has occurred. ? sec: second event 0 = no second event has occurred since the last clear. 1 = at least one second event has occurred since the last clear. ? timev: time event 0 = no time event has occurred since the last clear. 1 = at least one time event has occurred since the last clear. the time event is selected in the timevsel field in rtc_ctrl (control register) and can be any one of the following events: minute change, hour change, noon, midnight (day change). ? calev: calendar event 0 = no calendar event has occurred since the last clear. 1 = at least one calendar event has occurred since the last clear. the calendar event is selected in the calevsel field in rtc_cr and can be any one of the following events: week change, month change and year change. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C C calev timev sec alarm ackupd
105 6438fCatarmC21-jun-10 at91sam9g45 14.6.8 rtc status clear command register name: rtc_sccr address: 0xfffffdcc access type: write-only ? ackclr: acknowledge clear 0 = no effect. 1 = clears corresponding status flag in the status register (rtc_sr). ? alrclr: alarm clear 0 = no effect. 1 = clears corresponding status flag in the status register (rtc_sr). ? secclr: second clear 0 = no effect. 1 = clears corresponding status flag in the status register (rtc_sr). ? timclr: time clear 0 = no effect. 1 = clears corresponding status flag in the status register (rtc_sr). ? calclr: calendar clear 0 = no effect. 1 = clears corresponding status flag in the status register (rtc_sr). 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C C calclr timclr secclr alrclr ackclr
106 6438fCatarmC21-jun-10 at91sam9g45 14.6.9 rtc interrupt enable register name: rtc_ier address: 0xfffffdd0 access type: write-only ? acken: acknowledge update interrupt enable 0 = no effect. 1 = the acknowledge for update interrupt is enabled. ? alren: alarm interrupt enable 0 = no effect. 1 = the alarm interrupt is enabled. ? secen: second event interrupt enable 0 = no effect. 1 = the second periodic interrupt is enabled. ? timen: time event interrupt enable 0 = no effect. 1 = the selected time event interrupt is enabled. ? calen: calendar event interrupt enable 0 = no effect. ? 1 = the selected calendar event interrupt is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C C calen timen secen alren acken
107 6438fCatarmC21-jun-10 at91sam9g45 14.6.10 rtc interrupt disable register name: rtc_idr address: 0xfffffdd4 access type: write-only ? ackdis: acknowledge update interrupt disable 0 = no effect. 1 = the acknowledge for update interrupt is disabled. ? alrdis: alarm interrupt disable 0 = no effect. 1 = the alarm interrupt is disabled. ? secdis: second event interrupt disable 0 = no effect. 1 = the second periodic interrupt is disabled. ? timdis: time event interrupt disable 0 = no effect. 1 = the selected time event interrupt is disabled. ? caldis: calendar event interrupt disable 0 = no effect. 1 = the selected calendar event interrupt is disabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C C caldis timdis secdis alrdis ackdis
108 6438fCatarmC21-jun-10 at91sam9g45 14.6.11 rtc interrupt mask register name: rtc_imr address: 0xfffffdd8 access type: read-only ? ack: acknowledge update interrupt mask 0 = the acknowledge for update interrupt is disabled. 1 = the acknowledge for update interrupt is enabled. ? alr: alarm interrupt mask 0 = the alarm interrupt is disabled. 1 = the alarm interrupt is enabled. ? sec: second event interrupt mask 0 = the second periodic interrupt is disabled. 1 = the second periodic interrupt is enabled. ? tim: time event interrupt mask 0 = the selected time event interrupt is disabled. 1 = the selected time event interrupt is enabled. ? cal: calendar event interrupt mask 0 = the selected calendar event interrupt is disabled. 1 = the selected calendar event interrupt is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCcaltimsecalrack
109 6438fCatarmC21-jun-10 at91sam9g45 14.6.12 rtc valid entry register name: rtc_ver address: 0xfffffddc access type: read-only ? nvtim: non-valid time 0 = no invalid data has been detected in rtc_timr (time register). 1 = rtc_timr has contained invalid data since it was last programmed. ? nvcal: non-valid calendar 0 = no invalid data has been detected in rtc_calr (calendar register). 1 = rtc_calr has contained invalid data since it was last programmed. ? nvtimalr: non-valid time alarm 0 = no invalid data has been detected in rtc_timalr (time alarm register). 1 = rtc_timalr has contained invalid data since it was last programmed. ? nvcalalr: non-valid calendar alarm 0 = no invalid data has been detected in rtc_calalr (calendar alarm register). 1 = rtc_calalr has contained invalid data since it was last programmed. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCnvcalalrnvtimalrnvcalnvtim
110 6438fCatarmC21-jun-10 at91sam9g45
111 6438fCatarmC21-jun-10 at91sam9g45 15. periodic interval timer (pit) 15.1 description the periodic interval timer (pit) provides the operating systems scheduler interrupt. it is designed to offer maximum accuracy and efficient management, even for systems with long response time. 15.2 embedded characteristics ? includes a 20-bit periodic co unter, with less than 1s accuracy ? includes a 12-bit interval overlay counter ? real time os or linux/wince compliant tick generator 15.3 block diagram figure 15-1. periodic interval timer 15.4 functional description the periodic interval timer aims at providing pe riodic interrupts for use by operating systems. the pit provides a programmable overflow counter and a reset-on-read feature. it is built around two counters: a 20-bit cpiv counter and a 12-bit picnt counter. both counters work at master clock /16. 20-bit counter mck/16 piv pit_mr cpiv pit_pivr picnt 12-bit adder 0 0 read pit_pivr cpiv picnt pit_piir pits pit_sr set reset pitien pit_mr pit_irq 1 0 1 0 mck prescaler = ?
112 6438fCatarmC21-jun-10 at91sam9g45 the first 20-bit cpiv counter increments from 0 up to a programmable overflow value set in the field piv of the mode register (pit_mr). when the counter cpiv reaches this value, it resets to 0 and increments the periodic interval counter, picnt. the status bit pits in the status regis- ter (pit_sr) rises and triggers an interrupt , provided the interrupt is enabled (pitien in pit_mr). writing a new piv value in pit_mr does not reset/restart the counters. when cpiv and picnt values are obtained by reading the periodic interval value register (pit_pivr), the overflow counter (picnt) is rese t and the pits is cleared, thus acknowledging the interrupt. the value of picnt gives the number of periodic intervals elapsed since the last read of pit_pivr. when cpiv and picnt values are obtained by reading the periodic interval image register (pit_piir), there is no effect on the counters cpiv and picnt, nor on the bit pits. for exam- ple, a profiler can read pit_piir without clearing any pending interrupt, whereas a timer interrupt clears the interrupt by reading pit_pivr. the pit may be enabled/disabled using the pite n bit in the pit_mr register (disabled on reset). the piten bit only becomes effective when the cpiv value is 0. figure 15-2 illustrates the pit counting. after the pit enable bit is re set (piten= 0), the cpiv goes on counting until the piv value is reached, and is then reset. pit restarts counting, only if the piten is set again. the pit is stopped when the core enters debug state. figure 15-2. enabling/disabling pit with piten mck prescaler piv piv - 1 0 piten 10 0 15 cpiv 1 restarts mck prescaler 0 1 apb cycle read pit_pivr 0 picnt pits (pit_sr) mck apb interface apb cycle
113 6438fCatarmC21-jun-10 at91sam9g45 15.5 periodic interval time r (pit) user interface table 15-1. register mapping offset register name access reset 0x00 mode register pit_mr read-write 0x000f_ffff 0x04 status register pit_sr read-only 0x0000_0000 0x08 periodic interval value register pit_pivr read-only 0x0000_0000 0x0c periodic interval image register pit_piir read-only 0x0000_0000
114 6438fCatarmC21-jun-10 at91sam9g45 15.5.1 periodic interval timer mode register register name: pit_mr address: 0xfffffd30 access type: read/write ? piv: periodic interval value defines the value compared with the primary 20-bit counter of the periodic interval timer (cpiv). the period is equal to (piv + 1). ? piten: period interval timer enabled 0 = the periodic interval timer is disabled when the piv value is reached. 1 = the periodic interval timer is enabled. ? pitien: periodic interval timer interrupt enable 0 = the bit pits in pit_sr has no effect on interrupt. 1 = the bit pits in pit_sr asserts interrupt. 31 30 29 28 27 26 25 24 CCCCCCpitienpiten 23 22 21 20 19 18 17 16 CCCC piv 15 14 13 12 11 10 9 8 piv 76543210 piv
115 6438fCatarmC21-jun-10 at91sam9g45 15.5.2 periodic interval timer status register register name: pit_sr address: 0xfffffd34 access type: read-only ? pits: periodic interval timer status 0 = the periodic interval timer has not reached piv since the last read of pit_pivr. 1 = the periodic interval timer has reached piv since the last read of pit_pivr. 15.5.3 periodic interval timer value register register name: pit_pivr address: 0xfffffd38 access type: read-only reading this register clears pits in pit_sr. ? cpiv: current periodic interval value returns the current value of the periodic interval timer. ? picnt: periodic interval counter returns the number of occurrences of periodic intervals since the last read of pit_pivr. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCpits 31 30 29 28 27 26 25 24 picnt 23 22 21 20 19 18 17 16 picnt cpiv 15 14 13 12 11 10 9 8 cpiv 76543210 cpiv
116 6438fCatarmC21-jun-10 at91sam9g45 15.5.4 periodic interval timer image register register name: pit_piir address: 0xfffffd3c access type: read-only ? cpiv: current periodic interval value returns the current value of the periodic interval timer. ? picnt: periodic interval counter returns the number of occurrences of periodic intervals since the last read of pit_pivr. 31 30 29 28 27 26 25 24 picnt 23 22 21 20 19 18 17 16 picnt cpiv 15 14 13 12 11 10 9 8 cpiv 76543210 cpiv
117 6438fCatarmC21-jun-10 at91sam9g45 16. watchdog timer (wdt) 16.1 description the watchdog timer can be used to prevent system lock-up if the software becomes trapped in a deadlock. it features a 12-bit down counter that allows a watchdog period of up to 16 seconds (slow clock at 32.768 khz). it can generate a general reset or a processor reset only. in addition, it can be stopped while the processor is in debug mode or idle mode. 16.2 embedded characteristics ? 16-bit key-protected only-once-programmable counter ? windowed, prevents the processor to be in a dead-lock on the watchdog access 16.3 block diagram figure 16-1. watchdog timer block diagram = 0 10 set reset read wdt_sr or reset wdt_fault (to reset controller) set reset wdfien wdt_int wdt_mr slck 1/128 12-bit down counter current value wdd wdt_mr <= wdd wdv wdrstt wdt_mr wdt_cr reload wdunf wderr reload write wdt_mr wdt_mr wdrsten
118 6438fCatarmC21-jun-10 at91sam9g45 16.4 functional description the watchdog timer can be used to prevent system lock-up if the software becomes trapped in a deadlock. it is supplied with vddcore. it re starts with initial values on processor reset. the watchdog is built around a 12-bit down counter, which is loaded with the value defined in the field wdv of the mode register (wdt_m r). the watchdog timer uses the slow clock divided by 128 to establish the maximum watchdo g period to be 16 seconds (with a typical slow clock of 32.768 khz). after a processor reset, the value of wdv is 0xfff, corresponding to the maximum value of the counter with the external reset generation enabled (field wdrsten at 1 after a backup reset). this means that a default watchdog is running at reset, i.e., at power-up. the user must either disable it (by setting the wddis bit in wd t_mr) if he does not expect to use it or must reprogram it to meet the maximum watchdog period the application requires. the watchdog mode register (wdt_mr) can be written only once. only a processor reset resets it. writing the wdt_mr register reloads the timer with the newly programmed mode parameters. in normal operation, the user reloads the watchdog at regular intervals before the timer under- flow occurs, by writing the control register (wdt_cr) with the bit wdrstt to 1. the watchdog counter is then immediately reloaded from wdt_mr and restarted, and the slow clock 128 divider is reset and restarted. the wdt_cr register is write-protected. as a result, writing wdt_cr without the correct hard-coded key has no effect. if an underflow does occur, the wdt_fault signal to the reset controller is asserted if the bit wdrsten is set in the mode register (wdt_mr). moreover, the bit wdunf is set in the watchdog status register (wdt_sr). to prevent a software deadlock that continuously triggers the watchdog, the reload of the watchdog must occur while the watchdog c ounter is within a window between 0 and wdd, wdd is defined in the watchdog mode register wdt_mr. any attempt to restart the watchdog while the watchdog counter is between wdv and wdd results in a watchdog error, even if the watchdog is disabled. the bit wderr is updated in the wdt_sr and the wdt_fault signal to the reset controller is asserted. note that this feature can be disabled by programming a wdd value greater than or equal to the wdv value. in such a configuration, restarti ng the watchdog timer is permitted in the whole range [0; wdv] and does not generate an error. this is the default configuration on reset (the wdd and wdv values are equal). the status bits wdunf (watchdog underflow ) and wderr (watchdog error) trigger an inter- rupt, provided the bit wdfien is set in the mode register. the signal wdt_fault to the reset controller causes a watchdog reset if the wdrsten bit is set as already explained in the reset controller programmer datasheet. in that case, the processor and the watchdog timer are reset, and the wderr and wdunf flags are reset. if a reset is generated or if wdt_sr is read, the status bits are reset, the interrupt is cleared, and the wdt_fault signal to the reset controller is deasserted. writing the wdt_mr reloads and restarts the down counter. while the processor is in debug state or in idle mode, the counter may be stopped depending on the value programmed for the bits wdidlehlt and wddbghlt in the wdt_mr.
119 6438fCatarmC21-jun-10 at91sam9g45 figure 16-2. watchdog behavior 0 wdv wdd wdt_cr = wdrstt watchdog fault normal behavior watchdog error watchdog underflow fff if wdrsten is 1 if wdrsten is 0 forbidden window permitted window
120 6438fCatarmC21-jun-10 at91sam9g45 16.5 watchdog timer (wdt) user interface 16.5.1 watchdog timer control register register name: wdt_cr address: 0xfffffd40 access type: write-only ? wdrstt: watchdog restart 0: no effect. 1: restarts the watchdog. ?key: password should be written at value 0xa5. writing any other value in this field aborts the write operation. table 16-1. register mapping offset register name access reset 0x00 control register wdt_cr write-only - 0x04 mode register wdt_mr read-write once 0x3fff_2fff 0x08 status register wdt_sr read-only 0x0000_0000 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCwdrstt
121 6438fCatarmC21-jun-10 at91sam9g45 16.5.2 watchdog timer mode register register name: wdt_mr address: 0xfffffd44 access type: read-write once ? wdv: watchdog counter value defines the value loaded in the 12-bit watchdog counter. ? wdfien: watchdog fault interrupt enable 0: a watchdog fault (underflow or error) has no effect on interrupt. 1: a watchdog fault (underflow or error) asserts interrupt. ? wdrsten: watchdog reset enable 0: a watchdog fault (underflow or error) has no effect on the resets. 1: a watchdog fault (underflow or error) triggers a watchdog reset. ? wdrproc: watchdog reset processor 0: if wdrsten is 1, a watchdog fault (underflow or error) activates all resets. 1: if wdrsten is 1, a watchdog fault (underflow or error) activates the processor reset. ? wdd: watchdog delta value defines the permitted range for reloading the watchdog timer. if the watchdog timer value is less than or equal to w dd, writing wdt_cr with wdrs tt = 1 restarts the timer. if the watchdog timer value is greater than wdd, writing wdt_cr with wdrstt = 1 causes a watchdog error. ? wddbghlt: watchdog debug halt 0: the watchdog runs when the processor is in debug state. 1: the watchdog stops when the processor is in debug state. ? wdidlehlt: watchdog idle halt 0: the watchdog runs when the system is in idle mode. 1: the watchdog stops when the system is in idle state. ? wddis: watchdog disable 0: enables the watchdog timer. 1: disables the watchdog timer. 31 30 29 28 27 26 25 24 wdidlehlt wddbghlt wdd 23 22 21 20 19 18 17 16 wdd 15 14 13 12 11 10 9 8 wddis wdrproc wdrsten wdfien wdv 76543210 wdv
122 6438fCatarmC21-jun-10 at91sam9g45 16.5.3 watchdog timer status register register name: wdt_sr address: 0xfffffd48 access type: read-only ? wdunf: watchdog underflow 0: no watchdog underflow occurred since the last read of wdt_sr. 1: at least one watchdog underflow occurred since the last read of wdt_sr. ? wderr: watchdog error 0: no watchdog error occurred since the last read of wdt_sr. 1: at least one watchdog error occurred since the last read of wdt_sr. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCwderrwdunf
123 6438fCatarmC21-jun-10 at91sam9g45 17. shutdown controller (shdwc) 17.1 description the shutdown controller controls the pow er supplies vddio and vddcore and the wake-up detection on debounced input lines. 17.2 embedded characteristics the shut down controller is supplied on vddb u and allows a software-controllable shut down of the system through the pin shdn. an input change of the wkup pin or an alarm releases the shdn pin, and thus wakes up the system power supply. 17.3 block diagram figure 17-1. shutdown contro ller block diagram shutdown wake-up shutdown output controller shdn wkup0 shdw wkmode0 shutdown controller rtt alarm rttwken shdw_mr shdw_mr shdw_cr cptwk0 wakeup0 rttwk shdw_sr shdw_sr set set reset reset read shdw_sr read shdw_sr slck
124 6438fCatarmC21-jun-10 at91sam9g45 figure 17-2. shutdown contro ller block diagram 17.4 i/o lines description 17.5 product dependencies 17.5.1 power management the shutdown controller is continuously clock ed by slow clock. the power management con- troller has no effect on the behavior of the shutdown controller. shutdown wake-up shutdown output controller shdn wkup0 shdw wkmode0 shutdown controller rtc alarm rtt alarm rttwken rtcwken shdw_mr shdw_mr shdw_mr shdw_cr cptwk0 wakeup0 rttwk rtcwk shdw_sr shdw_sr shdw_sr set set set reset reset reset read shdw_sr read shdw_sr read shdw_sr slck table 17-1. i/o lines description name description type wkup0 wake-up 0 input input shdn shutdown output output
125 6438fCatarmC21-jun-10 at91sam9g45 17.6 functional description the shutdown controller manages the main power supply. to do so, it is supplied with vddbu and manages wake-up input pins and one output pin, shdn. a typical application connects the pin shdn to the shutdown input of the dc/dc converter pro- viding the main power supplies of the system , and especially vddcore and/or vddio. the wake-up inputs (wkup0) connect to any push-buttons or signal that wake up the system. the software is able to control the pin s hdn by writing the shutdown control register (shdw_cr) with the bit shdw at 1. the shutdow n is taken into account only 2 slow clock cycles after the write of shdw_ cr. this register is password-protected and so the value written should contain the correct key for the command to be taken into account. as a result, the system should be powered down. a level change on wkup0 is used as wake-up. wake-up is configured in the shutdown mode register (shdw_mr). the transition detector can be programmed to detect either a positive or negative transition or any level change on wkup 0. the detection can also be disabled. pro- gramming is performed by defining wkmode0. moreover, a debouncing circuit can be programmed for wkup0. the debouncing circuit filters pulses on wkup0 shorter than the programmed number of 16 slck cycles in cptwk0 of the shdw_mr register. if the programmed level change is detected on a pin, a counter starts. when the counter reaches the value programmed in the corresponding field, cptwk0, the shdn pin is released. if a new input change is detected before the counter reaches the corre- sponding value, the counter is stopped and cleared. wakeup0 of the status register (shdw_sr) reports the detection of the programmed events on wkup0 with a reset after the read of shdw_sr. the shutdown controller can be programmed so as to activate the wake-up using the rtt alarm (the detection of the rising edge of the rt t alarm is synchronized with slck). this is done by writing the shdw_mr register using the rttwken fields. when enabled, the detec- tion of the rtt alarm is reported in the rttwk bi t of the shdw_sr status register. it is reset after the read of shdw_sr. when using the rtt alarm to wake up the system, the user must ensure that the rtt alar m status flag is clear ed before shutting down the system. otherwise, no rising edge of the status flag may be detected and the wake-up fails. the shutdown controller can be programmed so as to activate the wake-up using the rtc alarm (the detection of the rising edge of the rtc alarm is synchronized with slck). this is done by writing the shdw_mr register using the rtcwken field. when enabled, the detection of the rtc alarm is reported in the rtcwk bit of the shdw_sr status register. it is reset after the read of shdw_sr. when using the rtc alarm to wake up th e system, the user must ensure that the rtc alarm status flag is cleared before shutting down the system. otherwise, no rising edge of the status flag may be detected and the wake-up fails fail.
126 6438fCatarmC21-jun-10 at91sam9g45 17.7 shutdown controller (shdwc) user interface 17.7.1 shutdown control register register name: shdw_cr address: 0xfffffd10 access type: write-only ? shdw: shutdown command 0 = no effect. 1 = if key is correct, asserts the shdn pin. ?key: password should be written at value 0xa5. writing any other value in this field aborts the write operation. table 17-2. register mapping offset register name access reset 0x00 shutdown control register shdw_cr write-only - 0x04 shutdown mode register shdw_mr read-write 0x0000_0003 0x08 shutdown status register shdw_sr read-only 0x0000_0000 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCshdw
127 6438fCatarmC21-jun-10 at91sam9g45 17.7.2 shutdown mode register register name: shdw_mr address: 0xfffffd14 access type: read/write ? wkmode0: wake-up mode 0 ? cptwk0: counter on wake-up 0 defines the number of 16 slow clock cycles, the level detection on the corresponding input pin shall last before the wake- up event occurs. because of the inte rnal synchronization of wkup0, the shdn pin is released (cptwk x 16 + 1) slow clock cycles after the event on wkup. ? rttwken: real-time timer wake-up enable 0 = the rtt alarm signal has no effect on the shutdown controller. 1 = the rtt alarm signal forces the de-assertion of the shdn pin. ? rtcwken: real-time clock wake-up enable 0 = the rtc alarm signal has no effect on the shutdown controller. 1 = the rtc alarm signal forces the de-assertion of the shdn pin. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCrtcwkenrttwken 15 14 13 12 11 10 9 8 CCCC 76543210 cptwk0 C C wkmode0 wkmode[1:0] wake-up inpu t transition selection 0 0 none. no detection is performed on the wake-up input 0 1 low to high level 1 0 high to low level 1 1 both levels change
128 6438fCatarmC21-jun-10 at91sam9g45 17.7.3 shutdown status register register name: shdw_sr address: 0xfffffd18 access type: read-only ? wakeup0: wake-up 0 status 0 = no wake-up event occurred on the corresponding wake-up input since the last read of shdw_sr. 1 = at least one wake-up event occurred on the corresponding wake-up input since the last read of shdw_sr. ? rttwk: real-time timer wake-up 0 = no wake-up alarm from the rtt occurred since the last read of shdw_sr. 1 = at least one wake-up alarm from the rtt occurred since the last read of shdw_sr. ? rtcwk: real-time clock wake-up 0 = no wake-up alarm from the rtc occurred since the last read of shdw_sr. 1 = at least one wake-up alarm from the rtc occurred since the last read of shdw_sr. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCrtcwkrttwk 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCw akeup0
129 6438fCatarmC21-jun-10 at91sam9g45 18. general purpose backup registers (gpbr) 18.1 description the system controller embeds four general-purpose backup registers. 18.2 embedded characteristics ? four 32-bit general-purpose backup registers 18.3 general purpose backup regist ers (gpbr) user interface table 18-1. register mapping offset register name access reset 0x0 general purpose backup register 0 sys_gpbr0 read-write C ... ... ... ... ... 0xc general purpose backup register 3 sys_gpbr3 read-write C
130 6438fCatarmC21-jun-10 at91sam9g45 18.3.0.1 general purpose backup register x name: sys_gpbrx addresses: 0xfffffd60 [0], 0xfffffd64 [1], 0xfffffd68 [2], 0xfffffd6c [3] type: read-write ? gpbr_valuex: value of gpbr x 31 30 29 28 27 26 25 24 gpbr_valuex 23 22 21 20 19 18 17 16 gpbr_valuex 15 14 13 12 11 10 9 8 gpbr_valuex 76543210 gpbr_valuex
131 6438fCatarmC21-jun-10 at91sam9g45 19. bus matrix (matrix) 19.1 description the bus matrix implements a multi-layer ahb, based on the ahb-lite protocol, that enables par- allel access paths between multiple ahb master s and slaves in a system, thus increasing the overall bandwidth. the bus matrix interconnects up to 16 ahb masters to up to 16 ahb slaves. the normal latency to connect a master to a slave is one cycle except for the default master of the accessed slave which is connected directly (zero cycle latency). the bus matrix user interface is compliant with arm advanced peripheral bus and provides a chip configuration user interface with registers that allow the bus matrix to support application specific features. 19.2 embedded characteristics ? 12-layer matrix, handling requests from 10 masters ? programmable arbitration strategy C fixed-priority arbitration C round-robin arbitration, either with no default master, last accessed default master or fixed default master ? burst management C breaking with slot cycle limit support C undefined burst length support ? one address decoder provided per master C three different slaves may be assigned to each decoded memory area: one for internal rom boot, one for internal flash boot, one after remap ? boot mode select C non-volatile boot memory can be internal rom or external memory on ebi_ncs0 C selection is made by general purpose nvm bit sampled at reset ? remap command C allows remapping of an internal sram in place of the boot non-volatile memory (rom or external flash) C allows handling of dynamic exception vectors 19.2.1 matrix masters the bus matrix of the at91sam9g45 manages masters, thus each master can perform an access concurrently with others, depending on whether the slave it accesses is available. each master has its own decoder, which can be defined specifically for each master. in order to simplify the addressing, all the masters have the same decodings.
132 6438fCatarmC21-jun-10 at91sam9g45 19.2.2 matrix slaves each slave has its own arbiter, thus allowing a di fferent arbitration per slave to be programmed. 19.2.3 masters to slaves access all the masters can normally access all the slaves. however, some paths do not make sense, such as allowing access from the ethernet mac to the internal peripherals. thus, these paths are forbidden or simply not wired, and shown as - in the following tables. the four ddr ports are connected differen tly according to th e application device. the user can disable the ddr mult i-port in the ddr multi-port regi ster (bit ddrm p_dis) in the chip configuration user interface. table 19-1. list of bus matrix masters master 0 arm926 ? instruction master 1 arm926 data master 2 peripheral dma controller (pdc) master 3 usb host ohci master 4 dma master 5 dma master 6 isi controller dma master 7 lcd dma master 8 ethernet mac dma master 9 usb device high speed dma master 10 usb host high speed ehci dma master 11 reserved table 19-2. list of bus matrix slaves slave 0 internal sram slave 1 internal rom usb ohci usb ehci udp high speed ram lcd user interface reserved slave 2 ddr port 0 slave 3 ddr port 1 slave 4 ddr port 2 slave 5 ddr port 3 slave 6 external bus interface slave 7 internal peripherals
133 6438fCatarmC21-jun-10 at91sam9g45 ? when the ddr multi-port is enabled (ddrmp_ dis=0), the arm instruction and data are respectively connected to ddr port 0 and dd r port 1. the other ma sters share ddr port 2 and ddr port 3. ? when the ddr multi-port is disabled (ddrmp_ dis=1), ddr port 1 is dedicated to the lcd controller. the remaining masters share ddr port 2 and ddr port 3. figure 19-1. ddr multi-port lcd dma arm d ddrmp_dis ddr_s1 ddr_s2 ddr_s3 arm d arm i matrix table 19-3. at91sam9g45 masters to slav es access ddrmp_dis = 0 master 0 1 2 3 4 & 5 6 7 8 9 10 11 slave arm 926 instr. arm 926 data pdc usb host ohci dma isi dma lcd dma ethernet mac usb device hs usb host ehci reserved 0 internal sram 0 x x x x x x - x x x - 1 internal rom x x x - - - - - x - - uhp ohcixx--------- uhp ehci x x - - - - - - - - - lcd user int. x x - - - - - - - - - udphs ram x x - - - - - - - - - reservedxx--------- 2ddr port 0x---------- 3ddr port 1-x--------- 4ddr port 2- -xxxx - xxxx 5ddr port 3- -xxxxxxxx- 6 ebi x x x x x x x x x x x 7 internal periph. x x x - x - - - - - -
134 6438fCatarmC21-jun-10 at91sam9g45 . table 19-5 summarizes the slave memory mapping for each connected master, depending on the remap status (rcbx bit in bus matrix ma ster remap control regi ster matrix_mrcr) and the bms state at reset. 19.3 memory mapping the bus matrix provides one decoder for every ahb master interface. the decoder offers each ahb master several memory mappings. in fact, depending on the product, each memory area may be assigned to several slaves. booting at the same address while using different ahb slaves (i.e. external ram, internal rom or internal flash, etc.) becomes possible. the bus matrix user interface provides mast er remap control regist er (matrix_mrcr) that performs remap action for every master independently. 19.4 special bus granting mechanism the bus matrix provides some speculative bus granting techniques in order to anticipate access requests from some masters. this mechanism reduc es latency at first access of a burst or single table 19-4. at91sam9g45 masters to slaves ac cess with ddrmp_di s = 1 (default) master 0 1 2 3 4 & 5 6 7 8 9 10 11 slave arm 926 instr. arm 926 data pdc usb host ohci dma isi dma lcd dma ethernet mac usb device hs usb host ehci reserved 0 internal sram 0 x x x x x x - x x x - 1 internal rom x x x - - - - - x - - uhp ohcixx--------- uhp ehcixx--------- lcd user int.xx--------- udphs ramxx--------- reserved xx--------- 2ddr port 0----------x 3ddr port 1------x---- 4ddr port 2 x - xxxx - xxx - 5ddr port 3 - xxxxx - xxx - 6 ebi xxxxxxxxxxx 7internal periph.xxx-x------ table 19-5. internal memory mapping master slave base address rcbx = 0 rcbx = 1 bms = 1 bms = 0 0x0000 0000 internal rom ebi ncs0 internal sram
135 6438fCatarmC21-jun-10 at91sam9g45 transfer as long as the slave is free from any other master access, but does not provide any ben- efit as soon as the slave is continuously acce ssed by more than one master, since arbitration is pipelined and then has no negative effect on the slave bandwidth or access latency. this bus granting mechanism sets a different default master for every slave. at the end of the current access, if no other re quest is pending, the slave remains connected to its associated default master. a slave can be as sociated with three kinds of default masters: no default master, last access master and fixed default master. to change from one kind of default master to another, the bus matrix user interface provides the slave configuration registers, one for each slave, that set a default master for each slave. the slave configuration register contains two fields: defmstr_type and fixed_defmstr. the 2-bit defmstr_type field selects the default mast er type (no default, last access master, fixed default master), whereas the 4-bit fixed_defmstr field selects a fixed default master pro- vided that defmstr_type is set to fi xed default master. please refer to section 19.7.2 bus matrix slave configuration registers on page 143 . 19.4.1 no default master after the end of the current access, if no other request is pending, the slave is disconnected from all masters. no default ma ster suits low-power mode. this configuration incurs one latency clock cycle for the first access of a burst after bus idle. arbitration without default master may be used for masters that perform significant bursts or sev- eral transfers with no idle in between, or if the slave bus bandwidth is widely used by one or more masters. this configuration provides no benefit on access latency or bandwidth when reaching maximum slave bus throughput whatever is the number of requesting masters. 19.4.2 last access master after the end of the current access, if no other request is pending, the slave remains connected to the last master that performed an access request. this allows the bus matrix to remove the one latency cycle for the last master that accessed the slave. other non privileged masters still get one lat ency clock cycle if they want to access the same slave. this technique is useful for master s that mainly perform single accesses or short bursts with some idle cycles in between. this configuration provides no benefit on access latency or bandwidth when reaching maximum slave bus throughput whatever is the number of requesting masters. 19.4.3 fixed default master after the end of the current access, if no other request is pending, the slave connects to its fixed default master. unlike last access master, the fixed master does not change unless the user modifies it by a software action (field fixed_defmstr of the related matrix_scfg). this allows the bus matrix arbiters to remove the one latency clock cycle for the fixed default master of the slave. every request attempted by this fixed default master will not cause any arbi- tration latency whereas other non privileged masters will still get one latency cycle. this technique is useful for a master that mainly perform single accesses or short bursts with some idle cycles in between.
136 6438fCatarmC21-jun-10 at91sam9g45 this configuration provides no benefit on access latency or bandwidth when reaching maximum slave bus throughput whatever is the number of requesting masters. 19.5 arbitration the bus matrix provides an arbitration mechanism that reduces latency when conflict cases occur, i.e. when two or more masters try to access the same slave at the same time. one arbiter per ahb slave is provided, thus ar bitrating each slave differently. the bus matrix provides the user with t he possibility of choosing betw een 2 arbitration types or mixing them for each slave: 1. round-robin arbitration (default) 2. fixed priority arbitration the resulting algorithm may be complemented by selecting a default master configuration for each slave. when a re-arbitration must be done, specific condi tions apply. see section 19.5.1 arbitration scheduling on page 136 . 19.5.1 arbitration scheduling each arbiter has the ability to arbitrate between two or more different master requests. in order to avoid burst breaking and also to provide the maximum throughput for slave interfaces, arbitra- tion may only take place during the following cycles: 1. idle cycles: when a slave is not connected to any master or is connected to a master which is not currently accessing it. 2. single cycles: when a slave is currently doing a single access. 3. end of burst cycles: when the current cycle is the last cycle of a burst transfer. for defined length burst, predicted end of burst matches the size of the transfer but is man- aged differently for undefined length burst. see undefined length burst arbitration on page 136 4. slot cycle limit: when the slot cycle counte r has reached the limit value indicating that the current master access is too long and must be broken. see slot cycle limit arbi- tration on page 137 19.5.1.1 undefined length burst arbitration in order to optimize ahb burst lengths and arbitration, it may be interesting to set a maximum for undefined length bursts (incr). the bus matrix prov ides specific logic in order to re-arbitrate before the end of the incr transfer. a predicted end of burst is used as a defined length burst transfer and can be selected from among the following undefined length burst type (ulbt) possibilities: 1. unlimited: no predicted end of burst is generated and theref ore incr burst transfer will not be broken by this way, but will be able to complete unless broken at the slot cycle limit. this is normally the default and should be let as is in order to be able to allow full 1 kilobyte ahb intra-boundary 256-beat word bursts performed by some atmel ahb masters. 2. 1-beat bursts: predicted end of burst is generated at each single transfer inside the incr transfer. 3. 4-beat bursts: predicted end of burst is generated at the end of each 4-beat boundary inside incr transfer.
137 6438fCatarmC21-jun-10 at91sam9g45 4. 8-beat bursts: predicted end of burst is generated at the end of each 8-beat boundary inside incr transfer. 5. 16-beat bursts: predicted end of burst is generated at the end of each 16-beat bound- ary inside incr transfer. 6. 32-beat bursts: predicted end of burst is generated at the end of each 32-beat bound- ary inside incr transfer. 7. 64-beat bursts: predicted end of burst is generated at the end of each 64-beat bound- ary inside incr transfer. 8. 128-beat bursts: predicted end of burst is generated at the end of each 128-beat boundary inside incr transfer. use of undefined length 16-beat bursts or less is discouraged since this generally decreases significantly overall bus bandwidth due to arbitration and slave latencies at each first access of a burst. if the master does not permanently and continuous ly request the same slave or has an intrinsi- cally limited average throughput, the ulbt should be let at its default unlimited value, knowing that the ahb specification natively limits all word bursts to 256 beats and double-word bursts to 128 beats because of its 1 kilobyte address boundaries. unless duly needed the ulbt should be let to its default 0 value for power saving. this selection can be done through the field ulbt of the master configuration registers (matrix_mcfg). 19.5.1.2 slot cycle limit arbitration the bus matrix contains specific logic to br eak long accesses, such as back to back undefined length bursts or very long bursts on a very sl ow slave (e.g., an external low speed memory). at each arbitration time a counter is loaded with t he value previously written in the slot_cycle field of the related slave configuration regist er (matrix_scfg) and decreased at each clock cycle. when the counter elapses, the arbiter has t he ability to re-arbitrate at the end of the cur- rent ahb bus access cycle. unless some master has a very tight access late ncy constraint which could lead to data overflow or underflow due to a badly undersized internal fifo with respect to its throughput, the slot cycle limit should be disabled (slot_cycle = 0) or let to its default maximum value in order not to inefficiently break long bursts performed by some atmel masters. however, the slot cycle limit should not be disabled in the very particular case of a master capable of accessing the slave by performing ba ck to back undefined length bursts shorter than the number of ulbt beats with no idle cycle in between, since in this case the arbitration could be frozen all along the bursts sequence. in most cases this feature is not needed and should be disabled for power saving. warning: this feature cannot prevent any slave from locking its access indefinitely. 19.5.2 arbitration priority scheme the bus matrix arbitration scheme is organized in priority pools. round-robin priority is used inside the highest and lowest priority pools , whereas fix level prior- ity is used between priority pools and inside the intermediate priority pools.
138 6438fCatarmC21-jun-10 at91sam9g45 for each slave, each master x is assigned to one of the slave priority pools through the priority registers for slaves (mxpr fields of matrix_pras and matrix_prbs). when evaluating masters requests, this programmed priority level always takes precedence. after reset, all the masters are belonging to the lowest priority pool (mxpr = 0) and so are granted bus access in a true round-robin fashion. the highest priority pool must be specifically re served for masters requiring very low access latency. if more than one master belong to this pool, these will be granted bus access in a biased round-robin fashion which allow tight and deterministic maximum access latency from ahb bus request. in fact, at worst, any currently high priority ma ster request will be granted after the current bus master access is ended and the other high priority pool masters, if any, have been granted once each. the lowest priority pool shares the remaining bus bandwidth between ahb masters. intermediate priority pools allow fine priority tuning. typically, a moderately latency critical mas- ter or a bandwidth only critical master will use such a priority level. the higher the priority level (mxpr value), the higher the master priority. all combination of mxpr values are allowed for all masters and slaves. for example some mas- ters might be assigned to the highest priority pool (round-robin) and the remaining masters to the lowest priority pool (round-robin), with no master for intermediate fix priority levels. if more than one master is requesting the slave bus, whatever are the respective masters priori- ties, no master will be granted the slave bus for two consecutiv e runs. a master can only get back to back grants as long as it is the only requesting master. 19.5.2.1 fixed priority arbitration this arbitration algorithm is the first and onl y applied between masters from distinct priority pools. it is also used inside priority pools other than the highest and lowest ones (intermediate priority pools). it allows the bus matrix arbiters to dispatch the requests from different masters to the same slave by using the fixed priority defined by the us er in the mxpr field for each master inside the matrix_pras and matrix_prbs priority registers. if two or more master requests are active at the same time, the master with the highest priority number mxpr is serviced first. inside intermediate priority pools, if two or more master requests with the same priority are active at the same time, the master with the highest number is serviced first. 19.5.2.2 round-robin arbitration this algorithm is only used inside the highest and lo west priority pools. it allows the bus matrix arbiters to dispatch the requests from different masters to the same slave in a fair way. if two or more master requests are active at the same time inside the priority pool, they are serviced in a round-robin increasing master number order.
139 6438fCatarmC21-jun-10 at91sam9g45 19.6 write protect registers to prevent any single software error that may corrupt matrix behavior, the entire matrix address space from address offset 0x000 to 0x 1fc can be write-protected by setting the wpen bit in the matrix write protect mode register (matrix_wpmr). if a write access to anywhere in the matrix address space from address offset 0x000 to 0x1fc is detected, then the wpvs flag in the matrix write protect st atus register (matrix_wpsr) is set and the field wpvsrc indicates in which register the write access has been attempted. the wpvs flag is reset by writing the matrix write protect mode register (matrix_wpmr) with the appropriate access key wpkey. the protected registers are: bus matrix master co nfiguration registers bus matrix slave configuration registers bus matrix priority registers a for slaves bus matrix priority registers b for slaves bus matrix master remap control register
140 6438fCatarmC21-jun-10 at91sam9g45 19.7 bus matrix (matrix) user interface table 19-6. register mapping offset register name access reset 0x0000 master configuration register 0 matrix_mcfg0 read-write 0x00000001 0x0004 master configuration register 1 matrix_mcfg1 read-write 0x00000000 0x0008 master configuration register 2 matrix_mcfg2 read-write 0x00000000 0x000c master configuration register 3 matrix_mcfg3 read-write 0x00000000 0x0010 master configuration register 4 matrix_mcfg4 read-write 0x00000000 0x0014 master configuration register 5 matrix_mcfg5 read-write 0x00000000 0x0018 master configuration register 6 matrix_mcfg6 read-write 0x00000000 0x001c master configuration register 7 matrix_mcfg7 read-write 0x00000000 0x0020 master configuration register 8 matrix_mcfg8 read-write 0x00000000 0x0024 master configuration register 9 matrix_mcfg9 read-write 0x00000000 0x0028 master configuration register 10 matrix_mcfg10 read-write 0x00000000 0x002c - 0x003c reserved C C C 0x0040 slave configuration register 0 matrix_scfg0 read-write 0x000001ff 0x0044 slave configuration register 1 matrix_scfg1 read-write 0x000001ff 0x0048 slave configuration register 2 matrix_scfg2 read-write 0x000001ff 0x004c slave configuration register 3 matrix_scfg3 read-write 0x000001ff 0x0050 slave configuration register 4 matrix_scfg4 read-write 0x000001ff 0x0054 slave configuration register 5 matrix_scfg5 read-write 0x000001ff 0x0058 slave configuration register 6 matrix_scfg6 read-write 0x000001ff 0x005c slave configuration register 7 matrix_scfg7 read-write 0x000001ff 0x0060 - 0x007c reserved C C C 0x0080 priority register a for slave 0 matrix_pras0 read-write 0x00000000 0x0084 priority register b for slave 0 matrix_prbs0 read-write 0x00000000 0x0088 priority register a for slave 1 matrix_pras1 read-write 0x00000000 0x008c priority register b for slave 1 matrix_prbs1 read-write 0x00000000 0x0090 priority register a for slave 2 matrix_pras2 read-write 0x00000000 0x0094 priority register b for slave 2 matrix_prbs2 read-write 0x00000000 0x0098 priority register a for slave 3 matrix_pras3 read-write 0x00000000 0x009c priority register b for slave 3 matrix_prbs3 read-write 0x00000000 0x00a0 priority register a for slave 4 matrix_pras4 read-write 0x00000000 0x00a4 priority register b for slave 4 matrix_prbs4 read-write 0x00000000 0x00a8 priority register a for slave 5 matrix_pras5 read-write 0x00000000 0x00ac priority register b for slave 5 matrix_prbs5 read-write 0x00000000 0x00b0 priority register a for slave 6 matrix_pras6 read-write 0x00000000 0x00b4 priority register b for slave 6 matrix_prbs6 read-write 0x00000000
141 6438fCatarmC21-jun-10 at91sam9g45 0x00b8 priority register a for slave 7 matrix_pras7 read-write 0x00000000 0x00bc priority register b for slave 7 matrix_prbs7 read-write 0x00000000 0x00c0 - 0x00fc reserved C C C 0x0100 master remap control register matrix_mrcr read-write 0x00000000 0x0104 - 0x010c reserved C C C 0x0110 - 0x01e0 chip configuration registers C C C 0x01e4 write protect mode regist er matrix_wpmr read-write 0x00000000 0x01e8 write protect status register matrix_wpsr read-only 0x00000000 table 19-6. register mapping (continued) offset register name access reset
142 6438fCatarmC21-jun-10 at91sam9g45 19.7.1 bus matrix master configuration registers name: matrix_mcfg0...matrix_mcfg10 address: 0xffffea00 access: read-write this register can only be written if the wpen bit is cleared in the write protect mode register . ? ulbt: undefined length burst type 0: unlimited length burst no predicted end of burst is generated and therefore incr bursts coming from this master can only be broken if the slave slot cycle limit is reached. if the slot cycle limit is not reached, the burst is normally completed by the master, at the lat- est, on the next ahb 1 kbyte address boundary, allowing up to 256-beat word bursts or 128-beat double-word bursts. 1: single access the undefined length burst is treated as a succession of single accesses, allowing re-arbitration at each beat of the incr burst. 2: 4-beat burst the undefined length burst is split into 4-beat bursts, allowing re-arbitration at each 4-beat burst end. 3: 8-beat burst the undefined length burst is split into 8-beat bursts, allowing re-arbitration at each 8-beat burst end. 4: 16-beat burst the undefined length burst is split into 16-beat bursts, allowing re-arbitration at each 16-beat burst end. 5: 32-beat burst the undefined length burst is split into 32-beat bursts, allowing re-arbitration at each 32-beat burst end. 6: 64-beat burst the undefined length burst is split into 64-beat bursts, allowing re-arbitration at each 64-beat burst end. 7: 128-beat burst the undefined length burst is split into 128-beat bursts, allowing re-arbitration at each 128-beat burst end. unless duly needed the ulbt should be let to its default 0 value for power saving. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCC ulbt
143 6438fCatarmC21-jun-10 at91sam9g45 19.7.2 bus matrix slave configuration registers name: matrix_scfg0...matrix_scfg7 address: 0xffffea40 access: read-write this register can only be written if the wpen bit is cleared in the write protect mode register . ? slot_cycle: maximum bus gr ant duration for masters when slot_cycle ahb clock cycles have elapsed since the last arbitration, a new arbitration takes place so as to let an other master access this slave. if an other master is re questing the slave bus, then the current master burst is broken. if slot_cycle = 0, the slot cycle limit feature is disabl ed and bursts always complete unless broken according to the ulbt. this limit has been placed in order to enforce arbitration so as to meet potential latency constraints of masters waiting for slave access or in the particular case of a master performing back to back undefined length bursts indefinitely freezing the arbitration. this limit must not be small. unreasonably small values break every burst and the bus matrix arbitrates without performing any data transfer. the default maximum value is usually an optimal conservative choice. in most cases this feature is not needed and should be disabled for power saving. see slot cycle limit arbitration on page 137 for details. ? defmstr_type: default master type 0: no default master at the end of the current slave access, if no other master request is pending, the slave is disconnected from all masters. this results in a one clock cycle latency for the first access of a burst transfer or for a single access. 1: last default master at the end of the current slave access, if no other master request is pending, the slave stays connected to the last master having accessed it. this results in not having one cl ock cycle latency when the last master tries to access the slave again. 2: fixed default master at the end of the current slave access, if no other master r equest is pending, the slave connec ts to the fixed master the number that has been written in the fixed_defmstr field. this results in not having one cl ock cycle latency when the fixed master tries to access the slave again. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 C C fixed_defmstr defmstr_type 15 14 13 12 11 10 9 8 CCCCCCCslot_cycle 76543210 slot_cycle
144 6438fCatarmC21-jun-10 at91sam9g45 ? fixed_defmstr: fixed default master this is the number of the defa ult master for this slave. only used if defmstr_type is 2. specifying the number of a mas- ter which is not connected to the selected slave is equivalent to setting defmstr_type to 0.
145 6438fCatarmC21-jun-10 at91sam9g45 19.7.3 bus matrix priority registers a for slaves name: matrix_pras0...matrix_pras7 addresses: 0xffffea80 [0], 0xffffea88 [1], 0xffffea90 [2], 0xffffea98 [3], 0xffffeaa0 [4], 0xffffeaa8 [5], 0xffffeab0 [6], 0xffffeab8 [7] access: read-write this register can only be written if the wpen bit is cleared in the write protect mode register . ? mxpr: master x priority fixed priority of master x for accessing the selected slave. the higher the number, the higher the priority. all the masters programmed with the same mxpr value for the slave make up a priority pool. round-robin arbitration is used inside the lowest (mxpr = 0) and highest (mxpr = 3) priority pools. fixed priority is used inside intermediate priority pools (mxpr = 1) and (mxpr = 2). see section 19.5.2 arbitration priority scheme for details. 31 30 29 28 27 26 25 24 CC m7pr CC m6pr 23 22 21 20 19 18 17 16 CC m5pr CC m4pr 15 14 13 12 11 10 9 8 CC m3pr CC m2pr 76543210 CC m1pr CC m0pr
146 6438fCatarmC21-jun-10 at91sam9g45 19.7.4 bus matrix priority registers b for slaves name: matrix_prbs0...matrix_prbs7 addresses: 0xffffea84 [0], 0xffffea8c [1], 0x ffffea94 [2], 0xffffea9c [3], 0xff ffeaa4 [4], 0xffffeaac [5], 0xffffeab4 [6], 0xffffeabc [7] access: read-write this register can only be written if the wpen bit is cleared in the write protect mode register . ? mxpr: master x priority fixed priority of master x for accessing the selected slave. the higher the number, the higher the priority. all the masters programmed with the same mxpr value for the slave make up a priority pool. round-robin arbitration is used inside the lowest (mxpr = 0) and highest (mxpr = 3) priority pools. fixed priority is used inside intermediate priority pools (mxpr = 1) and (mxpr = 2). see section 19.5.2 arbitration priority scheme for details. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCC C m10pr 76543210 CC m9pr CC m8pr
147 6438fCatarmC21-jun-10 at91sam9g45 19.7.5 bus matrix master remap control register name: matrix_mrcr address: 0xffffeb00 access: read-write this register can only be written if the wpen bit is cleared in the write protect mode register . ? rcb: remap command bit for master x 0: disable remapped address decoding for the selected master 1: enable remapped address decoding for the selected master 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 C C C C C rcb10 rcb9 rcb8 76543210 rcb7 rcb6 rcb5 rcb4 rcb3 rcb2 rcb1 rcb0
148 6438fCatarmC21-jun-10 at91sam9g45 19.7.6 chip configuration user interface table 19-7. chip configuration user interface offset register name access reset 0x0110 bus matrix tcm configuration register ccfg_tcmr read-write 0x00000000 0x0114 reserved C C C 0x0118 ddr multi-port register ccfg_ddrmpr read-write 0x00000001 0x011c - 0x0124 reserved C C C 0x0128 ebi chip select assignment register ccfg_ebicsa read-write 0x00010000 0x012c - 0x01fc reserved C C C
149 6438fCatarmC21-jun-10 at91sam9g45 19.7.6.1 bus matrix tcm configuration register name: ccfg_tcmr access: read-write reset: 0x0000_0000 ? itcm_size: size of itcm enabled memory block 000: 0 kb (no itcm memory) 110: 32 kb others: reserved ? dtcm_size: size of dtcm enabled memory block 000: 0 kb (no dtcm memory) 110: 32 kb 111: 64 kb others: reserved ? tcm_nws: tcm wait state 0: no tcm wait state 1: 1 tcm wait state (only for ration 3:1 or 4:1) 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCtcm_nwsCCC 76543210 dtcm_size itcm_size
150 6438fCatarmC21-jun-10 at91sam9g45 19.7.6.2 bus matrix ddr multi-port register register name: ccfg_ddrmpr access type: read-write reset: 0x0000_0001 ? ddrmp_dis: ddr multi-port disable 0: multi-port is enabled 1: multi-port is disabled 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCddrmp_dis
151 6438fCatarmC21-jun-10 at91sam9g45 19.7.6.3 ebi chip select assignment register name: ccfg_ebicsa access: read-write reset: 0x0001_0000 ? ebi_cs1a: ebi chip select 1 assignment 0 = ebi chip select 1 is assigned to the static memory controller. 1 = ebi chip select 1 is assigned to the sdram controller. ? ebi_cs3a: ebi chip select 3 assignment 0 = ebi chip select 3 is only assigned to the static memory controller and ebi_ncs3 behaves as defined by the smc. 1 = ebi chip select 3 is assigned to the static memory controller and the smartmedia logic is activated. ? ebi_cs4a: ebi chip select 4 assignment 0 = ebi chip select 4 is only assigned to the static memory controller and ebi_ncs4 behaves as defined by the smc. 1 = ebi chip select 4 is assigned to the static memory controller and the compact flash logic slot 0 is activated. ? ebi_cs5a: ebi chip select 5 assignment 0 = ebi chip select 5 is only assigned to the static memory controller and ebi_ncs5 behaves as defined by the smc. 1 = ebi chip select 5 is assigned to the static memory controller and the compact flash logic slot 1 is activated. ? ebi_dbpuc: ebi data bus pull-up configuration 0 = ebi d0 - d15 data bus bits are interna lly pulled-up to the vddiom1 power supply. 1 = ebi d0 - d15 data bus bits are not internally pulled-up. ? ebi_drive: ebi i/o drive configuration this allows to avoid overshoots and give the best perf ormances according to the bus load and external memories. ? ddr_drive: ddr2 dedicated po rt i/o slew rate selection this allows to avoid overshoots and give the best perf ormances according to the bus load and external memories. 0 = low drive, optimized for load capacitance < 30 pf. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 C C C C C ddr_drive ebi_drive 15 14 13 12 11 10 9 8 CCCCCCCebi_dbpuc 76543210 C C ebi_cs5a ebi_cs4a ebi_cs3a C ebi_cs1a C value drive configuration conditions 00 optimized for 1.8v powered memories with low drive maximum load capacitance < 30 pf 01 optimized for 3.3v powered memories with low drive maximum load capacitance < 30 pf 10 optimized for 1.8v powered memories with high drive maximum load capacitance < 55 pf 11 optimized for 3.3v powered memories with high drive maximum load capacitance < 55 pf
152 6438fCatarmC21-jun-10 at91sam9g45 1 = high drive, optimized for load capacitance < 55 pf. note: this concerns only stand-alone ddr controller.
153 6438fCatarmC21-jun-10 at91sam9g45 19.7.7 write protect mode register name: matrix_wpmr address: 0xffffebe4 access: read-write for more details on matrix_wpmr, refer to section 19.6 write protect registers on page 139 . ? wpen: write protect enable 0 = disables the write protect if wpkey corresponds to 0x4d4154 (mat in ascii). 1 = enables the write protect if wpkey corresponds to 0x4d4154 (mat in ascii). protects the entire matrix address space from address offset 0x000 to 0x1fc. ? wpkey: write protect key (write-only) should be written at value 0x4d4154 (mat in ascii). writing any other value in this field aborts the write operation of the wpen bit. always reads as 0. 31 30 29 28 27 26 25 24 wpkey 23 22 21 20 19 18 17 16 wpkey 15 14 13 12 11 10 9 8 wpkey 76543210 CCCCCCCwpen
154 6438fCatarmC21-jun-10 at91sam9g45 19.7.8 write protect status register name: matrix_wpsr address: 0xffffebe8 access: read-only for more details on matrix_wpsr, refer to section 19.6 write protect registers on page 139 . ? wpvs: write protect violation status 0: no write protect violation has occurred since the last write of the matrix_wpmr. 1: at least one write protect violation has occurred since the last write of the matrix_wpmr. ? wpvsrc: write protect violation source when wpvs is active, this field indica tes the register address offset in which a write access has be en attempted. otherwise it reads as 0. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 wpvsrc 15 14 13 12 11 10 9 8 wpvsrc 76543210 CCCCCCCwpvs
155 6438fCatarmC21-jun-10 at91sam9g45 20. external memories the product embeds two ddrsdr controllers: ddrsdrc0 and ddrsdrc1. figure 20-1. ddrsdr controllers ? ddrsdrc0 is a multi-port ddrsdr controller, standalone. it supports only ddr2 and lp- ddr devices. its user interf ace is located at 0xffffe600. ? ddrsdrc1 is a single-port ddrsdr controlle r, embedded in ebi. it supports ddr2, lpddr, sdr and lp-sdr devices. its user interface is located at 0xffffe400. both are described in section 22. ddr/sdr sdram controller (ddrsdrc) . all references to sdr and lpsdr must be ignored for ddrsdrc0, multi-port ddrsdr controller. all references to multi-port must be ignor ed for ddrsdrc1, ddrsdr controller embedded in ebi. 20.1 ddrsdrc0 multi-por t ddrsdr controller 20.1.1 description the ddr2 controller is dedicated to 4-port ddr2/lpddr support. data transfers are performed through a 16-bit data bus on one chip select. the ddr2 cont roller operates with 1.8v power supply (vddiom0). bu s mat r i x ddrsdrc0 po r t 2 po r t 1 po r t 0 ddr2 or lp-ddr device po r t 3 ddrsdrc1 ebi ddr2 or lp-ddr or sdr or lp-sdr device nand flash device nand flash controller compact flash device compact flash controller st a t i c m e m o r y device st a t i c m e m o r y controller
156 6438fCatarmC21-jun-10 at91sam9g45 20.1.2 embedded characteristics 20.1.2.1 ddr2/lpddr controller four ahb interfaces, management of all accesses maximizes memory bandwidth and mini- mizes transaction latency. ? supports ahb transfers: C word, half word, byte access. ? supports ddr-sdram 2, lpddr ? numerous configurations supported C 2k, 4k, 8k, 16k row address memory parts C ddr2 with four internal banks C ddr2/lpddr with 16-bit data path C one chip select for ddr2/lpddr de vice (256 mbytes address space) ? programming facilities C multibank ping-pong access (up to 4 banks opened at same time = reduces average latency of transactions) C timing parameters specified by software C automatic refresh operation, refresh rate is programmable C automatic update of ds, tcr and pasr parameters ? energy-saving capabilities C self-refresh, power-down and deep power modes supported ? power-up initialization by software ? cas latency of 2, 3 supported ? reset function supported (ddr2) ? auto precharge command not used ? on die termination not supported ? ocd mode not supported
157 6438fCatarmC21-jun-10 at91sam9g45 20.1.3 ddr2 controller block diagram figure 20-2. organization of the ddr2 ddr2 user interface bus matrix apb ahb address decoders ddr2 lpddr controller ddr_a0-ddr_a13 ddr_d0-ddr_d15 ddr_cs ddr_cke ddr_ras, ddr_cas ddr_clk,#ddr_clk ddr_dqs[0..1] ddr_dqm[0..1] ddr_we ddr_ba0, ddr_ba1 ddr_vref
158 6438fCatarmC21-jun-10 at91sam9g45 20.1.4 i/o lines description 20.1.5 product dependencies the pins used for interfacing the ddr2 memo ry are not multiplexe d with the pio lines. 20.1.6 implementation example the following hardware configuration is given for illustration only. the user should refer to the memory manufacturer we b site to check current device availability. table 20-1. ddr2 i/o lines description name function type active level ddr2/lpddr controller ddr_d0 - ddr_d15 data bus i/o ddr_a0 - ddr_a13 address bus output ddr_dqm0 - ddr_dqm1 data mask output ddr_dqs0 - ddr_dqs1 data strobe output ddr_vref reference voltage for ddr2 operations, typically 0.9v input ddr_cs chip select output low ddr_clk - ddr_clk# ddr2 differential clock output ddr_cke clock enable output high ddr_ras row signal output low ddr_cas column signal output low ddr_we write enable output low ddr_ba0 - ddr_ba1 bank select output
159 6438fCatarmC21-jun-10 at91sam9g45 20.1.6.1 2x8-bit ddr2 hardware configuration software configuration the following configuration has to be performed: ? initialize the ddr2 controller depending on the ddr2 device and system bus frequency. the ddr2 initialization se quence is described in the sub-section ddr2 device initialization of the ddrsdrc section. ras cas nwe cke ddr_d7 ddr_d3 ddr_d2 ddr_d4 ddr_d0 ddr_d1 ddr_d5 ddr_d6 ba0 ba1 ddr_a0 ddr_a1 ddr_a2 ddr_a3 ddr_a4 ddr_a5 ddr_a6 ddr_a7 ddr_a8 ddr_a9 ddr_a10 ddr_a11 ddr_a12 ddr_a13 ck nck cs ddr_vref ddr_vref ck nck cs ba0 ba1 ras cas nwe cke ddr_d15 ddr_d11 ddr_d10 ddr_d12 ddr_d8 ddr_d9 ddr_d13 ddr_d14 ddr_a0 ddr_a1 ddr_a2 ddr_a3 ddr_a4 ddr_a5 ddr_a6 ddr_a7 ddr_a8 ddr_a9 ddr_a10 ddr_a11 ddr_a12 ddr_a13 ddr_ras ddr_cas ddr_we ddr_cke ddr_ba1 ddr_ba0 ddr_nclk ddr_clk ddr_cs ddr_d[0..15] ddr_a[0..13] ddr_dqs1 ddr_dqm1 ddr_dqs0 ddr_dqm0 1v8 1v8 c64 100nf c64 100nf c73 100nf c73 100nf c74 100nf c74 100nf c69 100nf c69 100nf c65 100nf c65 100nf c63 100nf c63 100nf c72 100nf c72 100nf mt47h64m8cf-3 ddr2 sdram mn6 mt47h64m8cf-3 ddr2 sdram mn6 a0 h8 a1 h3 a2 h7 a3 j2 a4 j8 a5 j3 a6 j7 a7 k2 a8 k8 a9 k3 a10 h2 ba0 g2 odt f9 dq0 c8 dq1 c2 dq2 d7 dq3 d3 dq4 d1 dq5 d9 dq6 b1 dq7 b9 dqs b7 dqs a8 rdqs/dm b3 rdqs/nu a2 vdd h9 vdd l1 vddl e1 vref e2 vddq c9 vss a3 vss e3 vddq a9 vdd e9 rfu1 g1 rfu2 l3 cke f2 ck e8 ck f8 cas g7 ras f7 we f3 cs g8 vddq c1 vddq c3 vddq c7 vssq b2 vssq b8 vssq d2 vssq d8 vdd a1 vss j1 a11 k7 ba1 g3 a12 l2 a13 l8 vss k9 vssdl e7 vssq a7 rfu3 l7 c70 100nf c70 100nf c59 100nf c59 100nf mt47h64m8cf-3 ddr2 sdram mn7 mt47h64m8cf-3 ddr2 sdram mn7 a0 h8 a1 h3 a2 h7 a3 j2 a4 j8 a5 j3 a6 j7 a7 k2 a8 k8 a9 k3 a10 h2 ba0 g2 odt f9 dq0 c8 dq1 c2 dq2 d7 dq3 d3 dq4 d1 dq5 d9 dq6 b1 dq7 b9 dqs b7 dqs a8 rdqs/dm b3 rdqs/nu a2 vdd h9 vdd l1 vddl e1 vref e2 vddq c9 vss a3 vss e3 vddq a9 vdd e9 rfu1 g1 rfu2 l3 cke f2 ck e8 ck f8 cas g7 ras f7 we f3 cs g8 vddq c1 vddq c3 vddq c7 vssq b2 vssq b8 vssq d2 vssq d8 vdd a1 vss j1 a11 k7 ba1 g3 a12 l2 a13 l8 vss k9 vssdl e7 vssq a7 rfu3 l7 c75 100nf c75 100nf c62 100nf c62 100nf c68 100nf c68 100nf c71 100nf c71 100nf c76 100nf c76 100nf c56 100nf c56 100nf c55 100nf c55 100nf c60 100nf c60 100nf c67 100nf c67 100nf c66 100nf c66 100nf c58 100nf c58 100nf c57 100nf c57 100nf c61 100nf c61 100nf
160 6438fCatarmC21-jun-10 at91sam9g45 20.2 external bus interface (ebi) 20.2.1 description the external bus interface (ebi) is designed to ensure the successful data transfer between several external devices and the embedded memory controller of an arm-based device. the static memory, ddr, sdram and ecc contro llers are all featured external memory con- trollers on the ebi. these external memory controllers are capable of handling several types of external memory and peripheral devices, such as sram, prom, eprom, eeprom, flash, ddr2 and sdram. the ebi operates with 1.8v or 3.3v power supply (vddiom1). the ebi also supports the compactflash and the nand flash protocols via integrated circuitry that greatly reduces the requirements for external components. furthermore, the ebi handles data transfers with up to six external devices, each assigned to six address spaces defined by the embedded memory controller. data transfers are performed through a 16-bit or 32-bit data bus, an address bus of up to 26 bits, up to six chip select lines (ncs[5:0]) and several control pins that are generally multiplexed between the different external memory controllers. 20.2.2 embedded characteristics the at91sam9g45 features an external bus interface to interface to a wide range of external memories and to any parallel peripheral. 20.2.2.1 external bus interface ? integrates three external memory controllers: C static memory controller C ddr2/sdram controller C slc nand flash ecc controller ? additional logic for nand flash and compactflash ? optional full 32-bit external data bus ? up to 26-bit address bus (up to 64 mbytes linear per chip select) ? up to 6 chip selects, configurable assignment: C static memory controller on ncs0 C ddr2/sdram controller (sdcs) or static memory controller on ncs1 C static memory controller on ncs2 C static memory controller on ncs3, optional nand flash support C static memory controller on ncs 4 - ncs5, optional compactflash m support 20.2.2.2 static memory controller ? 8-, 16- or 32-bit data bus ? multiple access modes supported C byte write or byte select lines C asynchronous read in page mode supported (4- up to 32-byte page size) ? multiple device adaptability C control signals programmable setup, pulse and hold time for each memory bank ? multiple wait state management C programmable wait state generation C external wait request
161 6438fCatarmC21-jun-10 at91sam9g45 C programmable data float time ? slow clock mode supported 20.2.2.3 ddr2/sdr controller ? supports ddr/lpddr, sdr-sdram and lpsdr ? numerous configurations supported C 2k, 4k, 8k, 16k row address memory parts C sdram with four internal banks C sdr-sdram with 16- or 32- bit data path C ddr2/lpddr with 16- bit data path C one chip select for sdram device (256 mbyte address space) ? programming facilities C multibank ping-pong access (up to 4 banks opened at same time = reduces average latency of transactions) C timing parameters specified by software C automatic refresh operation, refresh rate is programmable C automatic update of ds, tcr and pasr parameters (lpsdr) ? energy-saving capabilities C self-refresh, power-down and deep power modes supported ? sdram power-up initialization by software ? cas latency of 2, 3 supported ? auto precharge command not used ? sdr-sdram with 16-bit datapath and eight columns not supported C clock frequency change in precharge power-down mode not supported 20.2.2.4 nand flash error corrected code controller ? tracking the accesses to a nand flash device by triggering on the corresponding chip select ? single bit error correction and 2-bit random detection. ? automatic hamming code calculation while writing C ecc value available in a register ? automatic hamming code calculation while reading C error report, including error flag, correctable error flag and word address being detected erroneous C support 8- or 16-bit nand flash devices with 512-, 1024-, 2048- or 4096-bytes pages
162 6438fCatarmC21-jun-10 at91sam9g45 20.2.3 ebi block diagram figure 20-3. organization of the external bus interface external bus interface d[15:0] a[15:2], a18 pio mux logic user interface chip select assignor static memory controller ddr2 lpddr sdram controller bus matrix apb ahb address decoders a16/ba0 a0/nbs0 a1/nwr2/nbs2 a17/ba1 ncs0 nrd/cfoe ncs1/sdcs nwr0/nwe/cfwe nwr1/nbs1/cfior nwr3/nbs3/cfiow sdck, sdck#, sdcke dqm[1:0] dqs[1:0] ras, cas sdwe d[31:16] a[24:19] a25/cfrnw ncs4/cfcs0 ncs5/cfcs1 ncs2 cfce1 cfce2 nwait sda10 nandoe nandwe nand flash logic compactflash logic ecc controller a21/nandale a22/nandcle ncs3/nandcs dqm[3:2]
163 6438fCatarmC21-jun-10 at91sam9g45 20.2.4 i/o lines description the connection of some signals through the mux logic is not direct and depends on the memory controller in use at the moment. table 20-3 on page 163 details the connections between the two memory controllers and the ebi pins. table 20-2. ebi i/o lines description name function type active level ebi ebi_d0 - ebi_d31 data bus i/o ebi_a0 - ebi_a25 address bus output ebi_nwait external wait signal input low smc ebi_ncs0 - ebi_ncs5 chip select lines output low ebi_nwr0 - ebi_nwr3 wri te signals output low ebi_nrd read signal output low ebi_nwe write enable output low ebi_nbs0 - ebi_nbs3 byte mask signals output low ebi for nand flash support ebi_nandcs nand flash chip select line output low ebi_nandoe nand flash output enable output low ebi_nandwe nand flash write enable output low ddr2/sdram controller ebi_sdck, ebi_sdck# ddr2/sdram differential clock output ebi_sdcke ddr2/sdram clock enable output high ebi_sdcs ddr2/sdram controller chip select line output low ebi_ba0 - ebi_ba1 bank select output ebi_sdwe ddr2/sdram write enable output low ebi_ras - ebi_cas row and column signal output low ebi_sda10 sdram address 10 line output table 20-3. ebi pins and memory controllers i/o lines connections ebix pins sdram i/o lines smc i/o lines ebi_nwr1/nbs1/cfior nbs1 nwr1 ebi_a0/nbs0 not supported smc_a0 ebi_a1/nbs2/nwr2 not supported smc_a1 ebi_a[11:2] sdramc_a[9:0] smc_a[11:2] ebi_sda10 sdramc_a10 not supported ebi_a12 not supported smc_a12 ebi_a[14:13] sdramc_a[ 12:11] smc_a[14:13] ebi_a[25:15] not supported smc_a[25:15] ebi_d[31:0] d[31:0] d[31:0]
164 6438fCatarmC21-jun-10 at91sam9g45 20.2.5 application example 20.2.5.1 hardware interface table 20-4 on page 164 details the connections to be applied between the ebi pins and the external devices for each memory controller. notes: 1. nwr1 enables upper byte writes. nwr0 enables lower byte writes. 2. nwrx enables corresponding byte x writes. (x = 0,1,2 or 3) 3. nbs0 and nbs1 enable respectively lower and upper bytes of the lower 16-bit word. 4. nbs2 and nbs3 enable respectively lower and upper bytes of the upper 16-bit word. table 20-4. ebi pins and external static devices connections signals: ebi_ pins of the interfaced device 8-bit static device 2 x 8-bit static devices 16-bit static device 4 x 8-bit static devices 2 x 16-bit static devices 32-bit static device controller smc d0 - d7 d0 - d7 d0 - d7 d0 - d7 d0 - d7 d0 - d7 d0 - d7 d8 - d15 C d8 - d15 d8 - d15 d8 - d15 d8 - 15 d8 - 15 d16 - d23 C C C d16 - d23 d16 - d23 d16 - d23 d24 - d31 C C C d24 - d31 d24 - d31 d24 - d31 a0/nbs0 a0 C nlb C nlb (3) be0 a1/nwr2/nbs2 a1 a0 a0 we (2) nlb (4) be2 a2 - a22 a[2:22] a[1:21] a[1:21] a[0:20] a[0:20] a[0:20] a23 - a25 (5) a[23:25] a[22:24] a[22:24] a[21:23] a[21:23] a[21:23] ncs0 cs cs cs cs cs cs ncs1/ddrsdcs cs cs cs cs cs cs ncs2 cs cs cs cs cs cs ncs3/nandcs cs cs cs cs cs cs ncs4/cfcs0 cs cs cs cs cs cs ncs5/cfcs1 cs cs cs cs cs cs nrd/cfoe oe oe oe oe oe oe nwr0/nwe we we (1) we we (2) we we nwr1/nbs1 C we (1) nub we (2) nub (3) be1 nwr3/nbs3 C C C we (2) nub (4) be3
165 6438fCatarmC21-jun-10 at91sam9g45 table 20-5. ebi pins and external device connections signals: ebi_ pins of the interfaced device ddr2/lpddr sdram compactflash compactflash true ide mode nand flash controller ddrc sdramc smc d0 - d7 d0 - d7 d0 - d7 d0 - d7 d0 - d7 i/o0-i/o7 d8 - d15 d8 - d15 d8 - d15 d8 - 15 d8 - 15 i/o8-i/o15 (4) d16 - d31 C d16 - d31 C C C a0/nbs0 C C a0 a0 C a1/nwr2/nbs2 C C a1 a1 C dqm0-dqm3 dqm0-dqm3 dqm0-dqm3 C C C dqs0-dqm1 dqs0-dqs1 C C C C a2 - a10 a[0:8] a[0:8] a[2:10] a[2:10] C a11 a9 a9 C C C sda10 C a10 C C C a12 C C C C C a13 - a14 a[11:12] a[11:12] C C C a15 a13 a13 C C C a16/ba0 ba0 ba0 C C C a17/ba1 ba1 ba1 C C C a18 - a20 C C C C C a21/nandale C C C C ale a22/nandcle C C reg reg cle a23 - a24 C C C C C a25 C C cfrnw (1) cfrnw (1) C ncs0 C C C C C ncs1/ddrsdcs ddrcs sdcs C C C ncs2 C C C C C ncs3/nandcs C C C C ce (3) ncs4/cfcs0 C C cfcs0 (1) cfcs0 (1) C ncs5/cfcs1 C C cfcs1 (1) cfcs1 (1) C nandoe C C C C oe nandwe C C C C we nrd/cfoe C C oe C C nwr0/nwe/cfwe C C we we C nwr1/nbs1/cfior C C ior ior C nwr3/nbs3/cfiow C C iow iow C cfce1 C C ce1 cs0 C cfce2 C C ce2 cs1 C sdck ck clk C C C sdck# ck# C C C C sdcke cke cke C C C ras ras ras C C C cas cas cas C C C
166 6438fCatarmC21-jun-10 at91sam9g45 notes: 1. not directly connected to the compac tflash slot. permits the control of the bi directional buffer between the ebi data b us and the compactflash slot. 2. any pio line. 3. ce connection depends on the nand flash. for standard nand flash devices, it must be connected to any free pio line. for "ce don't care" nand flash devices, it can be eit her connected to ncs3/nandcs or to any free pio line. 4. i/o8 - !/o15 pins used only for 16-bit nandflash device. 5. ebi_nwait signal is multiplexed with pc15. 20.2.5.2 connection examples figure 20-4 shows an example of connections be tween the ebi and external devices. figure 20-4. ebi connections to memory devices sdwe we we C C C nwait (5) CCwaitwaitC pxx (2) C C cd1 or cd2 cd1 or cd2 C pxx (2) CCC Cce (3) pxx (2) CCC C rdy table 20-5. ebi pins and external device connections (continued) signals: ebi_ pins of the interfaced device ddr2/lpddr sdram compactflash compactflash true ide mode nand flash controller ddrc sdramc smc ebi d0-d31 a2-a15 ras cas sdck sdcke sdwe a0/nbs0 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 nwr1/nbs1 a1/nwr2/nbs2 nwr3/nbs3 ncs1/sdcs d0-d7 d8-d15 a16/ba0 a17/ba1 a18-a25 a10 sda10 sda10 a2-a11, a13 ncs0 ncs2 ncs3 ncs4 ncs5 a16/ba0 a17/ba1 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 a10 sda10 a2-a11, a13 a16/ba0 a17/ba1 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 d16-d23 d24-d31 a10 sda10 a2-a11, a13 a16/ba0 a17/ba1 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 a10 sda10 a2-a11, a13 a16/ba0 a17/ba1 dqm0 dqm1 dqm3 dqm2 nrd/noe nwr0/nwe 128k x 8 sram 128k x 8 sram d0-d7 d0-d7 a0-a16 a0-a16 a1-a17 a1-a17 cs cs oe we d0-d7 d8-d15 oe we nrd/noe a0/nwr0/nbs0 nrd/noe nwr1/nbs1 sdwe sdwe sdwe sdwe dqm0-dqm3
167 6438fCatarmC21-jun-10 at91sam9g45 20.2.6 product dependencies 20.2.6.1 i/o lines the pins used for interfacing the external bus interface may be multiplexed with the pio lines. the programmer must first program the pio controller to assign the external bus interface pins to their peripheral function. if i/o lines of the external bus interface are not used by the applica- tion, they can be used for other purposes by the pio controller. 20.2.7 functional description the ebi transfers data between the internal ahb bus (handled by the bus matrix) and the exter- nal memories or peripheral devices. it controls the waveforms and the parameters of the external address, data and control buses and is composed of the following elements: ? the static memory controller (smc) ? the ddr2/sdram controller (ddr2sdramc) ? the ecc controller (ecc) ? a chip select assignment feature that assigns an ahb address space to the external devices ? a multiplex controller circuit that shares the pins between the different memory controllers ? programmable compactflash support logic ? programmable nand flash support logic 20.2.7.1 bus multiplexing the ebi offers a complete set of control signal s that share the 32-bit data lines, the address lines of up to 26 bits and the control signals through a multiplex logic operating in function of the memory area requests. multiplexing is specifically organized in or der to guarantee the maintenance of the address and output control lines at a stable state while no ex ternal access is being pe rformed. mult iplexing is also designed to respect the data float times defined in the memory controllers. furthermore, refresh cycles of the ddr2 and sdram are executed independently by the ddr2sdram con- troller without delaying the other external memory controller accesses. 20.2.7.2 pull-up control the ebi_csa registers in the chip configuration user interface permit enabling of on-chip pull- up resistors on the data bus lines not multiplexed with the pio controller lines. the pull-up resis- tors are enabled after reset. setting the ebix_dbpuc bit disables the pull-up resistors on the d0 to d15 lines. enabling the pull-up resistor on the d16-d31 lines can be performed by program- ming the appropriate pio controller. 20.2.7.3 static memory controller for information on the static memory controller, refer to the static me mory controller section. 20.2.7.4 ddr2sdram controller for information on the ddr2sdram contro ller, refer to the ddr2sdramc section. 20.2.7.5 ecc controller for information on the ecc contro ller, refer to the ecc section.
168 6438fCatarmC21-jun-10 at91sam9g45 20.2.7.6 compactflash support the external bus interface 0 integrates circuitry that interfaces to compactflash devices. the compactflash logic is driven by the st atic memory controller (smc) on the ncs4 and/or ncs5 address space. programming the ebi_cs 4a and/or ebi_cs5a bit of the ebi_csa reg- ister in the chip conf iguration user interface to the appropriate value enables this logic. (for details on this register, refer to the chip configuration user interface in the bus matrix section.) access to an external compactflash device is then made by accessing the address space reserved to ncs4 and/or ncs5 (i.e., between 0x5000 0000 and 0x5fff ffff for ncs4 and between 0x6000 0000 and 0x6fff ffff for ncs5). all compactflash modes (attribute memory, common memory, i/o and true ide) are sup- ported but the signals _iois16 (i/o and true ide modes) and _ata sel (true ide mode) are not handled. i/o mode, common memory mode, attribute memory mode and true ide mode within the ncs4 and/or ncs5 address space, the current transfer address is used to distinguish i/o mode, common memory mode, attribute memory mode and true ide mode. the different modes are accessed through a specific memory mapping as illustrated on figure 20-5 . a[23:21] bits of the transfer address are used to select the desired mode as described in table 20-6 on page 168 . figure 20-5. compactflash memory mapping note: the a22 pin is used to drive the reg signal of the compactflash device (except in true ide mode). cf address space attribute memory mode space common memory mode space i/o mode space true ide mode space true ide alternate mode space offset 0x00e0 0000 offset 0x00c0 0000 offset 0x0080 0000 offset 0x0040 0000 offset 0x0000 0000 table 20-6. compactflash mode selection a[23:21] mode base address 000 attribute memory 010 common memory 100 i/o mode 110 true ide mode 111 alternate true ide mode
169 6438fCatarmC21-jun-10 at91sam9g45 cfce1 and cfce2 signals to cover all types of access, the smc must be al ternatively set to drive 8-bit data bus or 16-bit data bus. the odd byte access on the d[7:0] bus is only possible when the smc is configured to drive 8-bit memory devices on the corresponding ncs pin (ncs4 or ncs5). the chip select register (dbw field in the corresponding chip select register) of the ncs4 and/or ncs5 address space must be set as shown in table 20-7 to enable the required access type. nbs1 and nbs0 are the byte selection signals from smc and are available when the smc is set in byte select mode on the corresponding chip select. the cfce1 and cfce2 waveforms are identical to the corresponding ncsx waveform. for details on these waveforms and timings, refer to the static memory controller section. read/write signals in i/o mode and true ide mode, the compactflash logic drives the read and write command signals of the smc on cfior and cfiow signals, while the cfoe and cfwe signals are deac- tivated. likewise, in common memory mode and attribute memory mode, the smc signals are driven on the cfoe and cfwe signals, while the cfior and cfiow are deactivated. figure 20-6 on page 170 demonstrates a schematic representation of this logic. attribute memory mode, common memory mode and i/o mode are supported by setting the address setup and hold time on the ncs4 (and/or ncs5) chip select to the appropriate values. for details on these signal waveforms, please refer to the section: setup and hold cycles of the static memory controller section. table 20-7. cfce1 and cfce2 truth table mode cfce2 cfce1 dbw comment smc access mode attribute memory nbs1 nbs0 16 bits access to even byte on d[7:0] byte select common memory nbs1 nbs0 16bits access to even byte on d[7:0] access to odd by te on d[15:8] byte select 1 0 8 bits access to odd byte on d[7:0] i/o mode nbs1 nbs0 16 bits access to even byte on d[7:0] access to odd by te on d[15:8] byte select 1 0 8 bits access to odd byte on d[7:0] true ide mode task file 1 0 8 bits access to even byte on d[7:0] access to odd byte on d[7:0] data register 1 0 16 bits access to even byte on d[7:0] access to odd by te on d[15:8] byte select alternate true ide mode control register alternate status read 01 dont care access to even byte on d[7:0] dont care drive address 0 1 8 bits access to odd byte on d[7:0] standby mode or address space is not assigned to cf 11C C C
170 6438fCatarmC21-jun-10 at91sam9g45 figure 20-6. compactflash read/write control signals multiplexing of compactflash signals on ebi pins table 20-9 on page 170 and table 20-10 on page 171 illustrate the multip lexing of the compact- flash logic signals with other ebi signals on the ebi pins. the ebi pins in table 20-9 are strictly dedicated to the compactflash interface as so on as the ebi_cs4a and/or ebi_cs5a field of the ebi_csa register in the chip configuration user interface is set. these pins must not be used to drive any other memory devices. the ebi pins in table 20-10 on page 171 remain shared between all memory areas when the corresponding compactflash interface is enabled (ebi_cs4a = 1 and/or ebi_cs5a = 1). smc nrd_noe nwr0_nwe a23 cfior cfiow cfoe cfwe 1 1 compactflash logic external bus interface 1 1 1 0 a22 1 0 1 0 1 0 table 20-8. compactflash mode selection mode base address cfoe cfwe cfior cfiow attribute memory common memory nrd nwr0_nwe 1 1 i/o mode 1 1 nrd nwr0_nwe true ide mode 0 1 nrd nwr0_nwe table 20-9. dedicated compactflash interface multiplexing pins compactflash signals ebi signals cs4a = 1 cs5a = 1 cs4a = 0 cs5a = 0 ncs4/cfcs0 cfcs0 ncs4 ncs5/cfcs1 cfcs1 ncs5
171 6438fCatarmC21-jun-10 at91sam9g45 application example figure 20-7 on page 171 illustrates an example of a comp actflash application. cfcs0 and cfrnw signals are not directly connected to the compactflash slot 0, but do control the direc- tion and the output enable of the buffers between the ebi and the compactflash device. the timing of the cfcs0 signal is identical to the ncs4 signal. moreover, the cfrnw signal remains valid throughout the transfer, as does the address bus. the compactflash _wait sig- nal is connected to the nwait input of the static memory controller. for details on these waveforms and timings, refer to the static memory controller section. figure 20-7. compactflash application example table 20-10. shared compactflash interface mu ltiplexing pins access to compactflash device access to other ebi devices compactflash sign als ebi signals nrd/cfoe cfoe nrd nwr0/nwe/cfwe cfwe nwr0/nwe nwr1/nbs1/cfior cfior nwr1/nbs1 nwr3/nbs3/cfiow cfiow nwr3/nbs3 a25/cfrnw cfrnw a25 compactflash connector ebi d[15:0] /oe dir _cd1 _cd2 /oe d[15:0] a25/cfrnw ncs4/cfcs0 cd (pio) a[10:0] a22/reg noe/cfoe a[10:0] _reg _oe _we _iord _iowr _ce1 _ce2 nwe/cfwe nwr1/cfior nwr3/cfiow cfce1 cfce2 _wait nwait
172 6438fCatarmC21-jun-10 at91sam9g45 20.2.7.7 nand flash support external bus interfaces integrate circuitr y that interfaces to nand flash devices. external bus interface the nand flash logic is driven by the static memory controller on the ncs3 address space. programming the ebi_cs3a field in the ebi_csa register in the chip configuration user inter- face to the appropriate value enables the nand flash logic. for details on this register, refer to the bus matrix section. access to an external nand flash device is then made by accessing the address space reserved to ncs3 (i.e., between 0x4000 0000 and 0x4fff ffff). the nand flash logic drives the read and write command signals of the smc on the nandoe and nandwe signals when the ncs3 signal is active. nandoe and nandwe are invalidated as soon as the transfer address fails to lie in the ncs3 address space. see figure 20-8 on page 172 for more information. for details on these waveforms, refer to the static memory controller section. nand flash signals the address latch enable and command latch enable signals on the nand flash device are driven by address bits a22 and a21 of the ebi address bus. the command, address or data words on the data bus of the nand flash device are distinguished by using their address within the ncsx address space. the chip enable (ce) signal of the device and the ready/busy (r/b) signals are connected to pio lines. the ce si gnal then remains asserted even when ncsx is not selected, preventing the device from returning to standby mode. figure 20-8. nand flash application example d[7:0] ale nandwe nandoe noe nwe a[22:21] cle ad[7:0] pio r/b ebi ce nand flash pio ncsx/nandcs not connected
173 6438fCatarmC21-jun-10 at91sam9g45 20.2.8 implementation examples the following hardware conf igurations are given for illustration only. the user should refer to the memory manufacturer we b site to check current device availability. 20.2.8.1 2x8-bit ddr2 on ebi hardware configuration software configuration ? assign ebi_cs1 to the ddr2 controller by setti ng the ebi_cs1a bit in the ebi chip select register located in the bus matrix memory space. ? initialize the ddr2 controller depending on the ddr2 device and system bus frequency. the ddr2 initialization se quence is described in the sub-section ddr2 device initialization of the ddrsdrc section.
174 6438fCatarmC21-jun-10 at91sam9g45 20.2.8.2 16-bit lpddr on ebi hardware configuration software configuration the following configuration has to be performed: ? assign ebi_cs1 to the ddr2 controller by setting the bit ebi_cs1a in the ebi chip select register located in the bus matrix memory space. ? initialize the ddr2 controller depending on the lp-ddr device and system bus frequency. the lp-ddr initialization sequence is described in the section low-power ddr1-sdram ini- tialization in ddr/sdr s dram controller (ddrsdrc).
175 6438fCatarmC21-jun-10 at91sam9g45 20.2.8.3 16-bit sdram hardware configuration software configuration the following configuration has to be performed: ? assign the ebi cs1 to the sdram controller by setting the bit ebi_cs1a in the ebi chip select assignment register locate d in the bus matrix memory space. ? initialize the sdram controller depending on the sdram device and system bus frequency. the data bus width is to be programmed to 16 bits. the sdram initialization sequence is described in the section sdram device initialization in sdram controller (sdramc).
176 6438fCatarmC21-jun-10 at91sam9g45 20.2.8.4 2x16-bit sdram hardware configuration software configuration the following configuration has to be performed: ? assign the ebi cs1 to the sdram controller by setting the bit ebi_cs1a in the ebi chip select assignment register locate d in the bus matrix memory space. ? initialize the sdram controller depending on the sdram device and system bus frequency. the data bus width is to be programmed to 32 bits. the data lines d[16..31] are multiplexed with pio lines and thus the dedicated pios must be programmed in peripheral mode in the pio controller. the sdram initialization sequence is described in the section sdram device initialization in sdram controller (sdramc). a10 a11 d4 a13 dqm0 d2 dqm2 a8 ba0 cas d10 ba1 d5 d12 a6 a3 d9 d14 d15 clk d23 d19 d18 d30 dqm1 d24 d26 a14 d31 d22 d28 d17 d25 d27 d16 d21 dqm3 d29 d20 a3 a4 a13 a9 sda10 a7 a6 a5 a10 a11 a14 a2 a8 d3 cke ras a9 d0 we a5 d6 d7 a2 sda10 d8 d1 a4 d13 d11 a7 sdcs ba0 ba1 clk cke cas ras we a[1..14] d[0..31] vddiom vddiom vddiom vddiom 256 mbits 256 mbits sdram c13 100nf c13 100nf c1 100nf c1 100nf c11 100nf c11 100nf r4 0r r4 0r c2 100nf c2 100nf c8 100nf c8 100nf c3 100nf c3 100nf mt48lc16m16a2 mn2 mt48lc16m16a2 mn2 a0 23 a1 24 a2 25 a3 26 a4 29 a5 30 a6 31 a7 32 a8 33 a9 34 a10 22 ba0 20 a12 36 dq0 2 dq1 4 dq2 5 dq3 7 dq4 8 dq5 10 dq6 11 dq7 13 dq8 42 dq9 44 dq10 45 dq11 47 dq12 48 dq13 50 dq14 51 dq15 53 vdd 1 vss 28 vss 41 vddq 3 vdd 27 n.c1 40 clk 38 cke 37 dqml 15 dqmh 39 cas 17 ras 18 we 16 cs 19 vddq 9 vddq 43 vddq 49 vssq 6 vssq 12 vssq 46 vssq 52 vdd 14 vss 54 a11 35 ba1 21 c4 100nf c4 100nf c5 100nf c5 100nf c12 100nf c12 100nf c6 100nf c6 100nf r3 470k r3 470k c9 100nf c9 100nf c14 100nf c14 100nf mt48lc16m16a2 mn1 mt48lc16m16a2p-75it mt48lc16m16a2 mn1 mt48lc16m16a2p-75it a0 23 a1 24 a2 25 a3 26 a4 29 a5 30 a6 31 a7 32 a8 33 a9 34 a10 22 ba0 20 a12 36 dq0 2 dq1 4 dq2 5 dq3 7 dq4 8 dq5 10 dq6 11 dq7 13 dq8 42 dq9 44 dq10 45 dq11 47 dq12 48 dq13 50 dq14 51 dq15 53 vdd 1 vss 28 vss 41 vddq 3 vdd 27 n.c1 40 clk 38 cke 37 dqml 15 dqmh 39 cas 17 ras 18 we 16 cs 19 vddq 9 vddq 43 vddq 49 vssq 6 vssq 12 vssq 46 vssq 52 vdd 14 vss 54 a11 35 ba1 21 r1 470k r1 470k r2 0r r2 0r c7 100nf c7 100nf c10 100nf c10 100nf
177 6438fCatarmC21-jun-10 at91sam9g45 20.2.8.5 8-bit nand flash hardware configuration software configuration the following configuration has to be performed: ? assign the ebi cs3 to the nand flash by setting the bit ebi_cs3a in the ebi chip select assignment register located in the bus matrix memory space ? reserve a21 / a22 for ale / cle functions. address and command latches are controlled respectively by setting to 1 the address bit a21 and a22 during accesses. ? configure a pio line as an input to manage the ready/busy signal. ? configure static memory contro ller cs3 setup, pulse, cycle and mode accordingly to nand flash timings, the data bus width and the system bus frequency. d6 d0 d3 d4 d2 d1 d5 d7 nandoe nandwe (any pio) (any pio) ale cle d[0..7] 3v3 3v3 2 gb tsop48 package u1 k9f2g08u0m u1 k9f2g08u0m we 18 n.c 6 vcc 37 ce 9 re 8 n.c 20 wp 19 n.c 5 n.c 1 n.c 2 n.c 3 n.c 4 n.c 21 n.c 22 n.c 23 n.c 24 r/b 7 n.c 26 n.c 27 n.c 28 i/o0 29 n.c 34 n.c 35 vss 36 pre 38 n.c 39 vcc 12 vss 13 ale 17 n.c 11 n.c 10 n.c 14 n.c 15 cle 16 n.c 25 n.c 33 i/o1 30 i/o3 32 i/o2 31 n.c 47 n.c 46 n.c 45 i/o7 44 i/o6 43 i/o5 42 i/o4 41 n.c 40 n.c 48 r2 10k r2 10k c2 100nf c2 100nf r1 10k r1 10k c1 100nf c1 100nf
178 6438fCatarmC21-jun-10 at91sam9g45 20.2.8.6 16-bit nand flash hardware configuration software configuration the software configuration is the same as for an 8-bit nand flash except for the data bus width programmed in the mode register of the static memory controller. d6 d0 d3 d4 d2 d1 d5 d7 d14 d8 d11 d12 d10 d9 d13 d15 nandoe nandwe (any pio) ale cle d[0..15] (any pio) 3v3 3v3 2 gb tsop48 package r1 10k r1 10k r2 10k r2 10k c2 100nf c2 100nf c1 100nf c1 100nf u1 mt29f2g16aabwp-et u1 mt29f2g16aabwp-et we 18 n.c 6 vcc 37 ce 9 re 8 n.c 20 wp 19 n.c 5 n.c 1 n.c 2 n.c 3 n.c 4 n.c 21 n.c 22 n.c 23 n.c 24 r/b 7 i/o0 26 i/o8 27 i/o1 28 i/o9 29 n.c 34 n.c 35 n.c 36 pre 38 n.c 39 vcc 12 vss 13 ale 17 n.c 11 n.c 10 n.c 14 n.c 15 cle 16 vss 25 i/o11 33 i/o2 30 i/o3 32 i/o10 31 i/o15 47 i/o7 46 i/o14 45 i/o6 44 i/o13 43 i/o5 42 i/o12 41 i/o4 40 vss 48
179 6438fCatarmC21-jun-10 at91sam9g45 20.2.8.7 nor flash on ncs0 hardware configuration software configuration the default configuration for the static memory controller, byte select mode, 16-bit data bus, read/write controlled by chip select, allows boot on 16-bit non-volatile memory at slow clock. for another configuration, configure the static memory controller cs0 setup, pulse, cycle and mode depending on flash timings and system bus frequency. a21 a22 a1 a2 a3 a4 a5 a6 a7 a8 a15 a9 a12 a13 a11 a10 a14 a16 d6 d0 d3 d4 d2 d1 d5 d7 d14 d8 d11 d12 d10 d9 d13 d15 a17 a20 a18 a19 d[0..15] a[1..22] nrst nwe ncs0 nrd 3v3 3v3 tsop48 package c2 100nf c2 100nf c1 100nf c1 100nf at49bv6416 u1 at49bv6416 u1 a0 25 a1 24 a2 23 a3 22 a4 21 a5 20 a6 19 a7 18 a8 8 a9 7 a10 6 a11 5 a12 4 a13 3 a14 2 a15 1 a16 48 a17 17 a18 16 a21 9 a20 10 a19 15 we 11 reset 12 wp 14 oe 28 ce 26 vpp 13 dq0 29 dq1 31 dq2 33 dq3 35 dq4 38 dq5 40 dq6 42 dq7 44 dq8 30 dq9 32 dq10 34 dq11 36 dq12 39 dq13 41 dq14 43 dq15 45 vccq 47 vss 27 vss 46 vcc 37
180 6438fCatarmC21-jun-10 at91sam9g45 20.2.8.8 compactflash hardware configuration software configuration the following configuration has to be performed: d15 d14 d13 d12 d10 d11 d9 d8 d7 d6 d5 d4 d2 d1 d0 d3 a10 a9 a8 a7 a3 a4 a5 a6 a0 a2 a1 cd1 cd2 cd2 cd1 we oe iowr iord ce2 ce1 reg wait# reset cf_d3 cf_d2 cf_d1 cf_d0 cf_d7 cf_d6 cf_d5 cf_d4 cf_d11 cf_d10 cf_d9 cf_d8 cf_d15 cf_d14 cf_d13 cf_d12 cf_a10 cf_a9 cf_a8 cf_a7 cf_a6 cf_a5 cf_a4 cf_a3 cf_a2 cf_a1 cf_a0 reg we oe iowr iord cf_a10 cf_a9 cf_a8 cf_a7 cf_a6 cf_a5 cf_a4 cf_a3 cf_a2 cf_a1 cf_a0 cf_d4 cf_d13 cf_d15 cf_d14 cf_d12 cf_d11 cf_d10 cf_d9 cf_d8 cf_d7 cf_d6 cf_d5 cf_d3 cf_d2 cf_d1 cf_d0 ce2 ce1 reset rdy/bsy rdy/bsy wait# cfwe (any pio) a25/cfrnw d[0..15] a[0..10] cfcsx a22/reg cfoe cfiow cfior nwait (any pio) cfce2 cfce1 (any pio) 3v3 3v3 3v3 3v3 3v3 3v3  cfirq cfrst memory & i/o mode (cfcs0 or cfcs1) mn2a sn74alvc32 mn2a sn74alvc32 3 1 2 c2 100nf c2 100nf mn1d 74alvch32245 mn1d 74alvch32245 4dir t3 4oe t4 4a1 n5 4a2 n6 4a3 p5 4a4 p6 4a5 r5 4a6 r6 4a7 t6 4a8 t5 4b1 n2 4b2 n1 4b3 p2 4b4 p1 4b5 r2 4b6 r1 4b7 t1 4b8 t2 mn1c 74alvch32245 mn1c 74alvch32245 3dir j3 3oe j4 3a1 j5 3a2 j6 3a3 k5 3a4 k6 3a5 l5 3a6 l6 3a7 m5 3a8 m6 3b1 j2 3b2 j1 3b3 k2 3b4 k1 3b5 l2 3b6 l1 3b7 m2 3b8 m1 r2 47k r2 47k mn3b sn74alvc125 mn3b sn74alvc125 6 4 5 r1 47k r1 47k mn1b 74alvch32245 mn1b 74alvch32245 2dir h3 2oe h4 2a1 e5 2a2 e6 2a3 f5 2a4 f6 2a5 g5 2a6 g6 2a7 h5 2a8 h6 2b1 e2 2b2 e1 2b3 f2 2b4 f1 2b5 g2 2b6 g1 2b7 h2 2b8 h1 vcc gnd mn4 sn74lvc1g125-q1 vcc gnd mn4 sn74lvc1g125-q1 5 1 2 3 4 mn3a sn74alvc125 mn3a sn74alvc125 3 1 2 r3 10k r3 10k mn2b sn74alvc32 mn2b sn74alvc32 6 4 5 mn3c sn74alvc125 mn3c sn74alvc125 8 9 10 r4 10k r4 10k c1 100nf c1 100nf j1 n7e50-7516vy-20 j1 n7e50-7516vy-20 gnd 1 d3 2 d4 3 d5 4 d6 5 d7 6 ce1# 7 a10 8 oe# 9 a9 10 a8 11 a7 12 vcc 13 a6 14 a5 15 a4 16 a3 17 a2 18 a1 19 a0 20 d0 21 d1 22 d2 23 wp 24 cd2# 25 cd1# 26 d11 27 d12 28 d13 29 d14 30 d15 31 ce2# 32 vs1# 33 iord# 34 iowr# 35 we# 36 rdy/bsy 37 vcc 38 csel# 39 vs2# 40 reset 41 wait# 42 inpack# 43 reg# 44 bvd2 45 bvd1 46 d8 47 d9 48 d10 49 gnd 50 mn1a 74alvch32245 mn1a 74alvch32245 1a1 a5 1a2 a6 1a3 b5 1a4 b6 1a5 c5 1a6 c6 1a7 d5 1a8 d6 1dir a3 1oe a4 1b1 a2 1b2 a1 1b3 b2 1b4 b1 1b5 c2 1b6 c1 1b7 d2 1b8 d1 mn3d sn74alvc125 mn3d sn74alvc125 11 12 13
181 6438fCatarmC21-jun-10 at91sam9g45 ? assign the ebi cs4 and/or ebi_cs5 to the compactflash slot 0 and/or slot 1 by setting the bit ebi_cs4a and/or ebi_cs5a in the ebi chip select assignment register located in the bus matrix memory space. ? the address line a23 is to select i/o (a23=1) or memory mode (a23=0) and the address line a22 for reg function. ? a22, a23, cfrnw, cfs0, cfcs1, cfce1 an d cfce2 signals are multiplexed with pio lines and thus the dedicated pios must be programmed in peripheral mode in the pio controller. ? configure a pio line as an output for cfrst and two others as an input for cfirq and card detect functions respectively. ? configure smc cs4 and/or smc_cs5 (for slot 0 or 1) setup, pulse, cycle and mode accordingly to compactflash timings and system bus frequency.
182 6438fCatarmC21-jun-10 at91sam9g45 20.2.8.9 compactflash true ide hardware configuration software configuration the following configuration has to be performed: d15 d14 d13 d12 d10 d11 d9 d8 d7 d6 d5 d4 d2 d1 d0 d3 a10 a9 a8 a7 a3 a4 a5 a6 a0 a2 a1 cd1 cd2 cf_d3 cf_d2 cf_d1 cf_d0 cf_d7 cf_d6 cf_d5 cf_d4 cf_d11 cf_d10 cf_d9 cf_d8 cf_d15 cf_d14 cf_d13 cf_d12 reset# cf_a10 cf_a9 cf_a8 cf_a7 cf_a6 cf_a5 cf_a4 cf_a3 cf_a2 cf_a1 cf_a0 cd2 cd1 iowr iord ce2 ce1 reg we oe iowr iord iordy cf_a0 cf_a2 cf_a1 cf_d4 cf_d13 cf_d15 cf_d14 cf_d12 cf_d11 cf_d10 cf_d9 cf_d8 cf_d7 cf_d6 cf_d5 cf_d3 cf_d2 cf_d1 cf_d0 ce2 ce1 reset# intrq iordy intrq cfwe (any pio) a25/cfrnw d[0..15] a[0..10] cfcsx a22/reg cfoe cfiow cfior nwait (any pio) cfce2 cfce1 (any pio) 3v3 3v3 3v3 3v3 3v3 3v3 3v3  cfirq cfrst true ide mode (cfcs0 or cfcs1) c2 100nf c2 100nf mn1d 74alvch32245 mn1d 74alvch32245 4dir t3 4oe t4 4a1 n5 4a2 n6 4a3 p5 4a4 p6 4a5 r5 4a6 r6 4a7 t6 4a8 t5 4b1 n2 4b2 n1 4b3 p2 4b4 p1 4b5 r2 4b6 r1 4b7 t1 4b8 t2 vcc gnd mn4 sn74lvc1g125-q1 vcc gnd mn4 sn74lvc1g125-q1 5 1 2 3 4 mn3c sn74alvc125 mn3c sn74alvc125 8 9 10 r4 10k r4 10k mn1c 74alvch32245 mn1c 74alvch32245 3dir j3 3oe j4 3a1 j5 3a2 j6 3a3 k5 3a4 k6 3a5 l5 3a6 l6 3a7 m5 3a8 m6 3b1 j2 3b2 j1 3b3 k2 3b4 k1 3b5 l2 3b6 l1 3b7 m2 3b8 m1 r3 10k r3 10k j1 n7e50-7516vy-20 j1 n7e50-7516vy-20 gnd 1 d3 2 d4 3 d5 4 d6 5 d7 6 cs0# 7 a10 8 ata sel# 9 a9 10 a8 11 a7 12 vcc 13 a6 14 a5 15 a4 16 a3 17 a2 18 a1 19 a0 20 d0 21 d1 22 d2 23 iois16# 24 cd2# 25 cd1# 26 d11 27 d12 28 d13 29 d14 30 d15 31 cs1# 32 vs1# 33 iord# 34 iowr# 35 we# 36 intrq 37 vcc 38 csel# 39 vs2# 40 reset# 41 iordy 42 inpack# 43 reg# 44 dasp# 45 pdiag# 46 d8 47 d9 48 d10 49 gnd 50 mn1a 74alvch32245 mn1a 74alvch32245 1a1 a5 1a2 a6 1a3 b5 1a4 b6 1a5 c5 1a6 c6 1a7 d5 1a8 d6 1dir a3 1oe a4 1b1 a2 1b2 a1 1b3 b2 1b4 b1 1b5 c2 1b6 c1 1b7 d2 1b8 d1 mn1b 74alvch32245 mn1b 74alvch32245 2dir h3 2oe h4 2a1 e5 2a2 e6 2a3 f5 2a4 f6 2a5 g5 2a6 g6 2a7 h5 2a8 h6 2b1 e2 2b2 e1 2b3 f2 2b4 f1 2b5 g2 2b6 g1 2b7 h2 2b8 h1 mn2a sn74alvc32 mn2a sn74alvc32 3 1 2 c1 100nf c1 100nf r2 47k r2 47k r1 47k r1 47k mn3b sn74alvc125 mn3b sn74alvc125 6 4 5 mn3d sn74alvc125 mn3d sn74alvc125 11 12 13 mn2b sn74alvc32 mn2b sn74alvc32 6 4 5 mn3a sn74alvc125 mn3a sn74alvc125 3 1 2
183 6438fCatarmC21-jun-10 at91sam9g45 ? assign the ebi cs4 and/or ebi_cs5 to the compactflash slot 0 and/or slot 1 by setting the bit ebi_cs4a and/or ebi_cs5a in the ebi chip select assignment register located in the bus matrix memory space. ? the address line a21 is to select alternate true ide (a21=1) or true ide (a21=0) modes. ? a21, cfrnw, cfs0, cfcs1, cfce1 and cfce2 signals are multiplexed with pio lines and thus the dedicated pios must be programmed in peripheral mode in the pio controller. ? configure a pio line as an output for cfrst and two others as an input for cfirq and card detect functions respectively. ? configure smc cs4 and/or smc_cs5 (for slot 0 or 1) setup, pulse, cycle and mode accordingly to compactflash timings and system bus frequency. 20.2.9 programmable i/o lines power supplies and drive levels the power supply pin vddiom1 accepts two voltage ranges. this allows the device to reach its maximum speed either out of 1.8v or 3.3v external memories. the maximum speed is 133 mhz on the sdck pin and #sdck signals loaded with 10 pf. the load on data/address and control signals are 30 pf for power supply at 1.8v and 50 pf for power supply at 3.3v. the data li nes frequency reaches 133 mhz in ddr2 mode. the other signals (control and address) do not go over 66 mhz. the ebi i/os accept two drive levels, high and low. this allows to avoid overshoots and give the best performance according to the bus load and external memories. refer to the ebi chip select assignment register for more details. the voltage ranges and the drive level are determined by programming ebi_drive field in the chip configuration registers locate d in the matrix user interface. at reset the selected def ault drive level is high. at reset, the selected voltage defaults to 3.3v typical and power supply pins can accept either 1.8v or 3.3v. the user must make sure to program the ebi voltage range before getting the device out of its slow clock mode. the user must make sure to program the ebi voltage range before getting the device out of its slow clock mode.
184 6438fCatarmC21-jun-10 at91sam9g45
185 6438fCatarmC21-jun-10 at91sam9g45 21. static memory controller (smc) 21.1 description the static memory controller (smc) generates the signals that control the access to the exter- nal memory devices or peripheral devices. it has 6 chip selects and a 26-bit address bus. the 32-bit data bus can be configured to interface with 8-, 16-, or 32-bit external devices. separate read and write control signals allow for direct memory and peripheral interfacing. read and write signal waveforms are fully parametrizable. the smc can manage wait requests from external devices to extend the current access. the smc is provided with an automatic slow clock mode. in slow clock mode, it switches from user- programmed waveforms to slow-rate specific waveforms on read and write signals. the smc supports asynchronous burst read in page mode access for page size up to 32 bytes. 21.2 i/o lines description 21.3 multiplexed signals table 21-1. i/o line description name description type active level ncs[7:0] static memory controller chip select lines output low nrd read signal output low nwr0/nwe write 0/write enable signal output low a0/nbs0 address bit 0/byte 0 select signal output low nwr1/nbs1 write 1/byte 1 select signal output low a1/nwr2/nbs2 address bit 1/write 2/byte 2 select signal output low nwr3/nbs3 write 3/byte 3 select signal output low a[25:2] address bus output d[31:0] data bus i/o nwait external wait signal input low table 21-2. static memory controller (smc) multiplexed signals multiplexed signal s related function nwr0 nwe byte-write or byte-select access, see byte write or byte select access on page 187 a0 nbs0 8-bit or 16-/32-bit data bus, see data bus width on page 187 nwr1 nbs1 byte-write or byte-select access see byte write or byte sele ct access on page 187 a1 nwr2 nbs2 8-/16-bit or 32-bit data bus, see data bus width on page 187 . byte-write or byte-select access, see byte write or byte select access on page 187 nwr3 nbs3 byte-write or byte-select access see byte write or byte sele ct access on page 187
186 6438fCatarmC21-jun-10 at91sam9g45 21.4 application example 21.4.1 hardware interface figure 21-1. smc connections to st atic memory devices 21.5 product dependencies 21.5.1 i/o lines the pins used for interfacing the static memory controller may be multiplexed with the pio lines. the programmer must first program the pio controller to assign the static memory con- troller pins to their peripheral function. if i/o lines of the smc are not used by the application, they can be used for other purposes by the pio controller. static memory controller d0-d31 a2 - a25 a0/nbs0 nwr0/nwe nwr1/nbs1 a1/nwr2/nbs2 nwr3/nbs3 128k x 8 sram d0 - d7 a0 - a16 oe we cs d0 - d7 d8-d15 a2 - a18 128k x 8 sram d0-d7 cs d16 - d23 d24-d31 128k x 8 sram d0-d7 cs nwr1/nbs1 nwr3/nbs3 nrd nwr0/nwe 128k x 8 sram d0 - d7 oe we cs nrd a1/nwr2/nbs2 ncs0 ncs1 ncs2 ncs3 ncs4 ncs5 ncs6 ncs7 a2 - a18 a0 - a16 nrd oe we oe we nrd a2 - a18 a0 - a16 a2 - a18 a0 - a16
187 6438fCatarmC21-jun-10 at91sam9g45 21.6 external memory mapping the smc provides up to 26 address lines, a[25:0]. this allows each chip select line to address up to 64 mbytes of memory. if the physical memory device co nnected on one chip select is smaller than 64 mbytes, it wraps around and appears to be repeated within this space. the smc correctly handles any valid access to the memory devi ce within the page (see figure 21-2 ). a[25:0] is only significant for 8-bit memory, a[25:1 ] is used for 16-bit memory, a[25:2] is used for 32-bit memory. figure 21-2. memory connections for eight external devices 21.7 connection to external devices 21.7.1 data bus width a data bus width of 8, 16, or 32 bits can be selected for each chip select. this option is con- trolled by the field dbw in smc_mode (mode register) for the corresponding chip select. figure 21-3 shows how to connect a 512k x 8-bit memory on ncs2. figure 21-4 shows how to connect a 512k x 16-bit memory on ncs2. figure 21-5 shows two 16-bit memories connected as a single 32-bit memory 21.7.2 byte write or byte select access each chip select with a 16-bit or 32-bit data bus can operate with one of two different types of write access: byte write or byte select access . this is controlled by the bat field of the smc_mode register for the corresponding chip select. nrd nwe a[25:0] d[31:0] 8 or 16 or 32 memory enable memory enable memory enable memory enable memory enable memory enable memory enable memory enable output enable write enable a[25:0] d[31:0] or d[15:0] or d[7:0] ncs3 ncs0 ncs1 ncs2 ncs7 ncs4 ncs5 ncs6 ncs[0] - ncs[7] smc
188 6438fCatarmC21-jun-10 at91sam9g45 figure 21-3. memory connection for an 8-bit data bus figure 21-4. memory connection for a 16-bit data bus figure 21-5. memory connection for a 32-bit data bus smc a0 nwe nrd ncs[2] a0 write enable output enable memory enable d[7:0] d[7:0] a[18:2] a[18:2] a1 a1 smc nbs0 nwe nrd ncs[2] low byte enable write enable output enable memory enable nbs1 high byte enable d[15:0] d[15:0] a[19:2] a[18:1] a[0] a1 d[31:16] smc nbs0 nwe nrd ncs[2] nbs1 d[15:0] a[20:2] d[31:16] nbs2 nbs3 byte 0 enable write enable output enable memory enable byte 1 enable d[15:0] a[18:0] byte 2 enable byte 3 enable
189 6438fCatarmC21-jun-10 at91sam9g45 21.7.2.1 byte write access byte write access supports one byte write signal per byte of the data bus and a single read signal. note that the smc does not allow boot in byte write access mode. ? for 16-bit devices: the smc provides nwr0 and nwr1 write signals for respectively byte0 (lower byte) and byte1 (upper byte) of a 16-bit bus. one single read signal (nrd) is provided. byte write access is used to connect 2 x 8-bit devices as a 16-bit memory. ? for 32-bit devices: nwr0, nwr1, nwr2 and nwr3, are the write signals of byte0 (lower byte), byte1, byte2 and byte 3 (upper byte) respectively. one single read signal (nrd) is provided. byte write access is used to connect 4 x 8-bit devices as a 32-bit memory. byte write option is illustrated on figure 21-6 . 21.7.2.2 byte select access in this mode, read/write operations can be enabled/disabled at a byte level. one byte-select line per byte of the data bus is provided. one nrd and one nwe signal control read and write. ? for 16-bit devices: the smc provides nbs0 and nbs1 selection signals for respectively byte0 (lower byte) and byte1 (upper byte) of a 16-bit bus. byte select access is used to connect one 16-bit device. ? for 32-bit devices: nbs0, nbs1, nbs2 and nbs3, are the selection signals of byte0 (lower byte), byte1, byte2 and byte 3 (upper byte) respectively. byte select access is used to connect two 16-bit devices. figure 21-7 shows how to connect two 16-bit devices on a 32-bit data bus in byte select access mode, on ncs3 (bat = byte select access).
190 6438fCatarmC21-jun-10 at91sam9g45 figure 21-6. connection of 2 x 8-bit devices on a 16-bit bus: byte write option 21.7.2.3 signal multiplexing depending on the bat, only the write signals or the byte select signals are used. to save ios at the external bus interface, control signals at the smc interface are multiplexed. table 21-3 shows signal multiplexing depending on the data bus width and the byte access type. for 32-bit devices, bits a0 and a1 are unused. for 16-bit devices, bit a0 of address is unused. when byte select option is selected, nwr1 to nwr3 are unused. when byte write option is selected, nbs0 to nbs3 are unused. smc a1 nwr0 nrd ncs[3] write enable read enable memory enable nwr1 write enable read enable memory enable d[7:0] d[7:0] d[15:8] d[15:8] a[24:2] a[23:1] a[23:1] a[0] a[0]
191 6438fCatarmC21-jun-10 at91sam9g45 figure 21-7. connection of 2x16-bit data bus on a 32-bit data bus (byte select option) smc nwe nrd ncs[3] write enable read enable memory enable nbs0 d[15:0] d[15:0] d[31:16] a[25:2] a[23:0] write enable read enable memory enable d[31:16] a[23:0] low byte enable high byte enable low byte enable high byte enable nbs1 nbs2 nbs3 table 21-3. smc multiplexed signal translation signal name 32-bit bus 16-bit bus 8-bit bus device type 1x32-bit 2x16-bit 4 x 8- bit 1x16-bit 2 x 8-bit 1 x 8-bit byte access type (bat) byte select byte select byte write byte select byte write nbs0_a0 nbs0 nbs0 nbs0 a0 nwe_nwr0 nwe nwe nwr0 nwe nwr0 nwe nbs1_nwr1 nbs1 nbs1 nwr1 nbs1 nwr1 nbs2_nwr2_a1 nbs2 nbs2 nwr2 a1 a1 a1 nbs3_nwr3 nbs3 nbs3 nwr3
192 6438fCatarmC21-jun-10 at91sam9g45 21.8 standard read and write protocols in the following sections, the byte access type is not considered. byte select lines (nbs0 to nbs3) always have the same timing as the a ad dress bus. nwe represents either the nwe sig- nal in byte select access type or one of the byte write lines (nwr0 to nwr3) in byte write access type. nwr0 to nwr3 have the same ti mings and protocol as nwe. in the same way, ncs represents one of the ncs[0..5] chip select lines. 21.8.1 read waveforms the read cycle is shown on figure 21-8 . the read cycle starts with the address setting on the memory address bus, i.e.: {a[25:2], a1, a0} for 8-bit devices {a[25:2], a1} for 16-bit devices a[25:2] for 32-bit devices. figure 21-8. standard read cycle 21.8.1.1 nrd waveform the nrd signal is characterized by a setu p timing, a pulse width and a hold timing. 1. nrd_setup: the nrd setup time is defined as the setup of address before the nrd falling edge; 2. nrd_pulse: the nrd pulse length is the time between nrd falling edge and nrd rising edge; 3. nrd_hold: the nrd hold time is defined as the hold time of a ddress after the nrd rising edge. a[25:2] nbs0,nbs1, nbs2,nbs3, a0, a1 ncs nrd_setup nrd_pulse nrd_hold mck nrd d[31:0] ncs_rd_setup ncs_rd_pulse ncs_rd_hold nrd_cycle
193 6438fCatarmC21-jun-10 at91sam9g45 21.8.1.2 ncs waveform similarly, the ncs signal can be divided into a setup time, pulse length and hold time: 1. ncs_rd_setup: the ncs setup time is defined as the setup time of address before the ncs falling edge. 2. ncs_rd_pulse: the ncs pulse length is the time between ncs falling edge and ncs rising edge; 3. ncs_rd_hold: the ncs hold time is defined as the hold time of address after the ncs rising edge. 21.8.1.3 read cycle the nrd_cycle time is defined as the total duration of the read cycle, i.e., from the time where address is set on the address bus to the point where address may change. the total read cycle time is equal to: nrd_cycle = nrd_setup + nrd_pulse + nrd_hold = ncs_rd_setup + ncs_rd_pulse + ncs_rd_hold all nrd and ncs timings are defined separately for each chip select as an integer number of master clock cycles. to ensure that the nrd and ncs timings are coherent, user must define the total read cycle instead of the hold timing. nrd_cycle implicitly defines the nrd hold time and ncs hold time as: nrd_hold = nrd_cycle - nrd setup - nrd pulse ncs_rd_hold = nrd_cycle - ncs_rd_setup - ncs_rd_pulse 21.8.1.4 null delay setup and hold if null setup and hold parame ters are programmed for nrd and/or ncs, nrd and ncs remain active continuously in case of consecutive read cycles in the same memory (see figure 21-9 ).
194 6438fCatarmC21-jun-10 at91sam9g45 figure 21-9. no setup, no hold on nrd and ncs read signals 21.8.1.5 null pulse programming null pulse is not permitted. pulse must be at least set to 1. a null value leads to unpredictable behavior. 21.8.2 read mode as ncs and nrd waveforms are defined independently of one other, the smc needs to know when the read data is available on the data bus. the smc does not compare ncs and nrd tim- ings to know which signal rises first. the r ead_mode parameter in the smc_mode register of the corresponding chip select indicates wh ich signal of nrd and ncs controls the read operation. 21.8.2.1 read is controlled by nrd (read_mode = 1): figure 21-10 shows the waveforms of a read operation of a typical asynchronous ram. the read data is available t pacc after the falling edge of nrd, and turn s to z after the rising edge of nrd. in this case, the read_mode must be set to 1 (read is controlled by nrd), to indicate that data is available with the rising edge of nrd. the smc samples the read data internally on the rising edge of master clock that generates the rising edge of nrd, whatever the pro- grammed waveform of ncs may be. mck nrd_pulse ncs_rd_pulse nrd_cycle nrd_pulse nrd_pulse ncs_rd_pulse ncs_rd_pulse nrd_cycle nrd_cycle a[25:2] nbs0,nbs1, nbs2,nbs3, a0, a1 ncs nrd d[31:0]
195 6438fCatarmC21-jun-10 at91sam9g45 figure 21-10. read_mode = 1: data is sampled by smc before the rising edge of nrd 21.8.2.2 read is controlled by ncs (read_mode = 0) figure 21-11 shows the typical read cycle of an lcd module. the read data is valid t pacc after the falling edge of the ncs signal and remains va lid until the rising edge of ncs. data must be sampled when ncs is raised. in that case, the read_mode must be set to 0 (read is controlled by ncs): the smc internally samples the data on the rising edge of master clock that generates the rising edge of ncs, whatever the programmed waveform of nrd may be. figure 21-11. read_mode = 0: data is sampled by smc before the rising edge of ncs data sampling t pacc mck a[25:2] nbs0,nbs1, nbs2,nbs3, a0, a1 ncs nrd d[31:0] data sampling t pacc mck d[31:0] a[25:2] nbs0,nbs1, nbs2,nbs3, a0, a1 ncs nrd
196 6438fCatarmC21-jun-10 at91sam9g45 21.8.3 write waveforms the write protocol is similar to the read protocol. it is depicted in figure 21-12 . the write cycle starts with the address setting on the memory address bus. 21.8.3.1 nwe waveforms the nwe signal is characterized by a setu p timing, a pulse width and a hold timing. 1. nwe_setup: the nwe setup time is defined as the setup of address and data before the nwe falling edge; 2. nwe_pulse: the nwe pulse length is the time between nwe falling edge and nwe rising edge; 3. nwe_hold: the nwe hold time is defined as the hold time of address and data after the nwe rising edge. the nwe waveforms apply to all byte-write lines in byte write access mode: nwr0 to nwr3. 21.8.3.2 ncs waveforms the ncs signal waveforms in write operation are not the same that those applied in read opera- tions, but are separately defined: 1. ncs_wr_setup: the ncs setup time is defined as the setup time of address before the ncs falling edge. 2. ncs_wr_pulse: the ncs pulse length is the time between ncs falling edge and ncs rising edge; 3. ncs_wr_hold: the ncs hold time is defined as the hold time of address after the ncs rising edge. figure 21-12. write cycle a [25:2] nbs0, nbs1, nbs2, nbs3, a0, a1 ncs nwe_setup nwe_pulse nwe_hold mck nwe ncs_wr_setup ncs_wr_pulse ncs_wr_hold nwe_cycle
197 6438fCatarmC21-jun-10 at91sam9g45 21.8.3.3 write cycle the write_cycle time is defined as the total durat ion of the write cycle, that is, from the time where address is set on the address bus to the point where address may change. the total write cycle time is equal to: nwe_cycle = nwe_setup + nwe_pulse + nwe_hold = ncs_wr_setup + ncs_wr_pulse + ncs_wr_hold all nwe and ncs (write) timings are defined separately for each chip select as an integer num- ber of master clock cycles. to ensure that the nwe and ncs timings are coherent, the user must define the total wr ite cycle instead of the hold timing. this implicitly defines the nwe hold time and ncs (write) hold times as: nwe_hold = nwe_cycle - nwe_setup - nwe_pulse ncs_wr_hold = nwe_cycle - ncs_wr_setup - ncs_wr_pulse 21.8.3.4 null delay setup and hold if null setup parameters are programmed for nwe and/or ncs, nwe and/or ncs remain active continuously in case of consecutive write cycles in the same memory (see figure 21-13 ). how- ever, for devices that perform write operations on the rising edge of nwe or ncs, such as sram, either a setup or a hold must be programmed. figure 21-13. null setup and hold values of ncs and nwe in write cycle 21.8.3.5 null pulse programming null pulse is not permitted. pulse must be at least set to 1. a null value leads to unpredictable behavior. ncs mck nwe, nwr0, nwr1, nwr2, nwr3 d[31:0] nwe_pulse ncs_wr_pulse nwe_cycle nwe_pulse ncs_wr_pulse nwe_cycle nwe_pulse ncs_wr_pulse nwe_cycle a [25:2] nbs0, nbs1, nbs2, nbs3, a0, a1
198 6438fCatarmC21-jun-10 at91sam9g45 21.8.4 write mode the write_mode parameter in th e smc_mode register of the corresponding chip select indi- cates which signal controls the write operation. 21.8.4.1 write is controlled by nwe (write_mode = 1): figure 21-14 shows the waveforms of a write operation with write_mode set to 1. the data is put on the bus during the pulse and hold steps of the nwe signal. the internal data buffers are turned out after the nwe_setup time, and until the end of the write cycle, regardless of the programmed waveform on ncs. figure 21-14. write_mode = 1. the write ope ration is controlled by nwe 21.8.4.2 write is controlle d by ncs (write_mode = 0) figure 21-15 shows the waveforms of a write operation with write_mode set to 0. the data is put on the bus during the pulse and hold steps of the ncs signal. the internal data buffers are turned out after the ncs_wr_setup time, and until the end of the write cycle, regardless of the programmed waveform on nwe. mck d[31:0] ncs a [25:2] nbs0, nbs1, nbs2, nbs3, a0, a1 nwe, nwr0, nwr1, nwr2, nwr3
199 6438fCatarmC21-jun-10 at91sam9g45 figure 21-15. write_mode = 0. the write ope ration is controlled by ncs 21.8.5 coding timing parameters all timing parameters are defined for one chip select and are grouped together in one smc_register according to their type. the smc_setup register groups the definition of all setup parameters: ? nrd_setup, ncs_rd_setup, nwe_setup, ncs_wr_setup the smc_pulse register groups the definition of all pulse parameters: ? nrd_pulse, ncs_rd_pulse, nwe_pulse, ncs_wr_pulse the smc_cycle register groups the definition of all cycle parameters: ? nrd_cycle, nwe_cycle table 21-4 shows how the timing parameters are coded and their permitted range. 21.8.6 reset values of timing parameters table 21-8 gives the default value of timing parameters at reset. mck d[31:0] ncs nwe, nwr0, nwr1, nwr2, nwr3 a [25:2] nbs0, nbs1, nbs2, nbs3, a0, a1 table 21-4. coding and range of timing parameters coded value number of bits effective value permitted range coded value effective value setup [5:0] 6 128 x setup[5] + setup[4:0] 0 31 0 128+31 pulse [6:0] 7 256 x pulse[6] + pulse[5:0] 0 63 0 256+63 cycle [8:0] 9 256 x cycle[8:7] + cycle[6:0] 0 127 0 256+127 0 512+127 0 768+127
200 6438fCatarmC21-jun-10 at91sam9g45 21.8.7 usage restriction the smc does not check the validity of the user-programmed parameters. if the sum of setup and pulse parameters is larger than the corresponding cycle parameter, this leads to unpre- dictable behavior of the smc. for read operations: null but positive setup and hold of address and nrd and/or ncs can not be guaranteed at the memory interface because of the propagation dela y of theses signals through external logic and pads. if positive setup and hold values must be verified, then it is strictly recommended to pro- gram non-null values so as to cover possible skews between address, ncs and nrd signals. for write operations: if a null hold value is programmed on nwe, the smc can guarantee a positive hold of address, byte select lines, and ncs signal after the rising edge of nwe. this is true for write_mode = 1 only. see early read wait state on page 201 . for read and write operations: a null value for pulse parameters is forbidden and may lead to unpredictable behavior. in read and write cycles, the setup and hold time parameters are defined in reference to the address bus. for external devices that require setup and hold time between ncs and nrd sig- nals (read), or between ncs and nwe signals (write), these setup and hold times must be converted into setup and hold times in reference to the address bus. 21.9 automatic wait states under certain circumstances, the smc automatica lly inserts idle cycles between accesses to avoid bus contention or operation conflict. 21.9.1 chip select wait states the smc always inserts an idle cycle between 2 transfers on separate chip selects. this idle cycle ensures that there is no bus contention between the de-activation of one device and the activation of the next one. during chip select wait state, all control li nes are turned inactive: nbs0 to nbs3, nwr0 to nwr3, ncs[0..5], nrd lines are all set to 1. figure 21-16 illustrates a chip select wait state between access on chip select 0 and chip select 2.
201 6438fCatarmC21-jun-10 at91sam9g45 figure 21-16. chip select wait state between a read access on ncs0 and a write access on ncs2 21.9.2 early read wait state in some cases, the smc inserts a wait state cycle between a write access and a read access to allow time for the write cycle to end before the subsequent read cycle begins. this wait state is not generated in addition to a chip select wait state. the early read cycle thus only occurs between a write and read access to the same memory device (same chip select). an early read wait state is automatically inserted if at least one of the following conditions is valid: ? if the write controlling signal has no hold time and the read controlling signal has no setup time ( figure 21-17 ). ? in ncs write controlled mode (write_mode = 0), if there is no hold timing on the ncs signal and the ncs_rd_setup parameter is set to 0, regardless of the read mode ( figure 21-18 ). the write operation must end with a ncs rising edge. without an early read wait state, the write operation could not complete properly. ? in nwe controlled mode (write_mode = 1) and if there is no hold timing (nwe_hold = 0), the feedback of the write control signal is used to control address, data, chip select and byte select lines. if the external write control signal is not inactivated as expected due to load capacitances, an early read wait state is inserted and address, data and control signals are maintained one more cycle. see figure 21-19 . a[25:2] nbs0, nbs1, nbs2, nbs3, a0,a1 ncs0 nrd_cycle chip select wait state nwe_cycle mck ncs2 nrd nwe d[31:0] read to write wait state
202 6438fCatarmC21-jun-10 at91sam9g45 figure 21-17. early read wait state: write with no hold followe d by read with no setup figure 21-18. early read wait state: ncs cont rolled write with no hold followed by a read with no ncs setup write cycle early read wait state mck nrd nwe read cycle no setup no hold d[31:0] nbs0, nbs1, nbs2, nbs3, a0, a1 a[25:2] write cycle (write_mode = 0) early read wait state mck nrd ncs read cycle (read_mode = 0 or read_mode = 1) no setup no hold d[31:0] nbs0, nbs1, nbs2, nbs3, a0,a1 a[25:2]
203 6438fCatarmC21-jun-10 at91sam9g45 figure 21-19. early read wait state: nwe-controlled write with no hold followed by a read with one set-up cycle 21.9.3 reload user configuration wait state the user may change any of the configuration parameters by writing the smc user interface. when detecting that a new user configuration has been written in the user interface, the smc inserts a wait state before starting the next access. the so called reload user configuration wait state is used by the smc to load the new set of parameters to apply to next accesses. the reload configuration wait state is not applied in addition to the chip select wait state. if accesses before and after re-programming the user interface are made to different devices (chip selects), then one single chip select wait state is applied. on the other hand, if accesses before and after writing the user interface are made to the same device, a reload configuration wait state is inserted, even if the change does not concern the current chip select. 21.9.3.1 user procedure to insert a reload configuration wait state, the smc detects a write access to any smc_mode register of the user interface. if the user only modifies timing registers (smc_setup, smc_pulse, smc_cycle registers) in the user interface, he must validate the modification by writing the smc_mode, even if no change was made on the mode parameters. the user must not change the configuration parameters of an smc chip select (setup, pulse, cycle, mode) if accesses are performed on this cs during the modification. any change of the chip select parameters, while fetching the code from a memory connected on this cs, may lead a [25:2] nbs0, nbs1, nbs2, nbs3, a0, a1 write cycle (write_mode = 1) early read wait state mck nrd internal write controlling signal external write controlling signal (nwe) d[31:0] read cycle (read_mode = 0 or read_mode = 1) no hold read setup = 1
204 6438fCatarmC21-jun-10 at91sam9g45 to unpredictable behavior. the instructions used to modify the parameters of an smc chip select can be executed from the internal ram or from a memory connected to another cs. 21.9.3.2 slow clock mode transition a reload configuration wait state is also inserted when the slow clock mode is entered or exited, after the end of the current transfer (see slow clock mode on page 215 ). 21.9.4 read to write wait state due to an internal mechanism, a wait cycle is always inserted between consecutive read and write smc accesses. this wait cycle is referred to as a read to write wait stat e in this document. this wait cycle is applied in add ition to chip select and reload user configuration wait states when they are to be inserted. see figure 21-16 on page 201 .
205 6438fCatarmC21-jun-10 at91sam9g45 21.10 data float wait states some memory devices are slow to release the exte rnal bus. for such devices, it is necessary to add wait states (data float wait states) after a read access: ? before starting a read access to a different external memory ? before starting a write access to the same device or to a different external one. the data float output time (t df ) for each external memory device is programmed in the tdf_cycles field of the smc_mode register for the corresponding chip select. the value of tdf_cycles indicates the number of data float wait cycles (between 0 and 15) before the external device releases the bus, and represents the time allowed for the data output to go to high impedance after the memory is disabled. data float wait states do not delay internal memory accesses. hence, a single access to an external memory with long t df will not slow down the executio n of a program from internal memory. the data float wait states management depends on the read_mode and the tdf_mode fields of the smc_mode register for the corresponding chip select. 21.10.1 read_mode setting the read_mode to 1 indicates to the smc that the nrd signal is responsible for turn- ing off the tri-state buffers of the external memory device. the data float period then begins after the rising edge of the nrd sign al and lasts tdf_cycles mck cycles. when the read operation is controlled by the ncs signal (read_mode = 0), the tdf field gives the number of mck cycles during which the data bus remains busy after the rising edge of ncs. figure 21-20 illustrates the data float period in nrd-controlled mode (read_mode =1), assuming a data float period of 2 cycles (tdf_cycles = 2). figure 21-21 shows the read oper- ation when controlled by ncs (read_mode = 0) and the tdf_cycles parameter equals 3.
206 6438fCatarmC21-jun-10 at91sam9g45 figure 21-20. tdf period in nrd controlled read access (tdf = 2) figure 21-21. tdf period in ncs controlled read operation (tdf = 3) nbs0, nbs1, nbs2, nbs3, a0, a1 ncs nrd controlled read operation tpacc mck nrd d[31:0] tdf = 2 clock cycles a[25:2] ncs tdf = 3 clock cycles tpacc mck d[31:0] ncs controlled read operation a[25:2] nbs0, nbs1, nbs2, nbs3, a0,a1 nrd
207 6438fCatarmC21-jun-10 at91sam9g45 21.10.2 tdf optimization enabled (tdf_mode = 1) when the tdf_mode of the smc_mode register is set to 1 (tdf optimization is enabled), the smc takes advantage of the setup period of the next access to optimize the number of wait states cycle to insert. figure 21-22 shows a read access controlled by nrd, followed by a write access controlled by nwe, on chip select 0. chip se lect 0 has been programmed with: nrd_hold = 4; read_mode = 1 (nrd controlled) nwe_setup = 3; write_mode = 1 (nwe controlled) tdf_cycles = 6; tdf_mode = 1 (optimization enabled). figure 21-22. tdf optimization: no tdf wait states are inserted if the tdf period is over when the next access begins 21.10.3 tdf optimization disabled (tdf_mode = 0) when optimization is disabled, tdf wait states are inserted at the end of the read transfer, so that the data float period is ended when the second access begins. if the hold period of the read1 controlling signal overlaps the data float period, no additional tdf wait st ates will be inserted. figure 21-23 , figure 21-24 and figure 21-25 illustrate the cases: ? read access followed by a read access on another chip select, ? read access followed by a write access on another chip select, ? read access followed by a write access on the same chip select, with no tdf optimization. a [25:2] ncs0 mck nrd nwe d[31:0] read to write wait state tdf_cycles = 6 read access on ncs0 (nrd controlled) nrd_hold= 4 nwe_setup= 3 write access on ncs0 (nwe controlled)
208 6438fCatarmC21-jun-10 at91sam9g45 figure 21-23. tdf optimization disabled (tdf mode = 0). tdf wait states between 2 read accesses on different chip selects figure 21-24. tdf mode = 0: tdf wait states between a read and a write access on different chip selects tdf_cycles = 6 tdf_cycles = 6 tdf_mode = 0 (optimization disabled) a[ 25:2] read1 cycle chip select wait state mck read1 controlling signal (nrd) read2 controlling signal (nrd) d[31:0] read1 hold = 1 read 2 cycle read2 setup = 1 5 tdf wait states nbs0, nbs1, nbs2, nbs3, a0, a1 tdf_cycles = 4 tdf_cycles = 4 tdf_mode = 0 (optimization disabled) a [25:2] read1 cycle chip select wait state read to write wait state mck read1 controlling signal (nrd) write2 controlling signal (nwe) d[31:0] read1 hold = 1 write2 cycle write2 setup = 1 2 tdf wait states nbs0, nbs1, nbs2, nbs3, a0, a1
209 6438fCatarmC21-jun-10 at91sam9g45 figure 21-25. tdf mode = 0: tdf wait states between read and write accesses on the same chip select 21.11 external wait any access can be extended by an external device using the nw ait input signal of the smc. the exnw_mode field of the smc_mode register on the corresponding chip select must be set to either to 10 (frozen mode) or 11 (ready mode). when the exnw_mode is set to 00 (disabled), the nwait signal is simply ignored on the correspo nding chip select. the nwait signal delays the read or write operation in regards to the read or write controlling signal, depending on the read and write modes of the corresponding chip select. 21.11.1 restriction when one of the exnw_mode is enabled, it is mandatory to program at least one hold cycle for the read/write controlling signal. for that reason, the nwait signal cannot be used in page mode ( ?asynchronous page mode? on page 218 ), or in slow clock mode ( ?slow clock mode? on page 215 ). the nwait signal is assumed to be a response of the external device to the read/write request of the smc. then nwait is examined by the smc only in the pulse state of the read or write controlling signal. the assertion of the nwait signal outside th e expected period has no impact on smc behavior. tdf_cycles = 5 tdf_cycles = 5 tdf_mode = 0 (optimization disabled) a [25:2] read1 cycle read to write wait state mck read1 controlling signal (nrd) write2 controlling signal (nwe) d[31:0] read1 hold = 1 write2 cycle write2 setup = 1 4 tdf wait states nbs0, nbs1, nbs2, nbs3, a0, a1
210 6438fCatarmC21-jun-10 at91sam9g45 21.11.2 frozen mode when the external device asserts the nwait signal (active low), and after internal synchroniza- tion of this signal, the smc state is frozen, i.e., smc internal counters are frozen, and all control signals remain unchanged. when the resynchronized nwait signal is deasserted, the smc completes the access, resuming the access from the point where it was stopped. see figure 21- 26 . this mode must be selected when the external device uses the nwait signal to delay the access and to freeze the smc. the assertion of the nwait sign al outside the expected period is ignored as illustrated in figure 21-27 . figure 21-26. write access with nwait assertion in frozen mode (exnw_mode = 10) exnw_mode = 10 (frozen) write_mode = 1 (nwe_controlled) nwe_pulse = 5 ncs_wr_pulse = 7 a [25:2] mck nwe ncs 432 1 110 1 4 5 63222210 write cycle d[31:0] nwait frozen state nbs0, nbs1, nbs2, nbs3, a0,a1 internally synchronized nwait signal
211 6438fCatarmC21-jun-10 at91sam9g45 figure 21-27. read access with nwait assertion in frozen mode (exnw_mode = 10) exnw_mode = 10 (frozen) read_mode = 0 (ncs_controlled) nrd_pulse = 2, nrd_hold = 6 ncs_rd_pulse =5, ncs_rd_hold =3 a [25:2] mck ncs nrd 10 43 43 2 555 22 0 210 210 1 read cycle assertion is ignored nwait internally synchronized nwait signal frozen state nbs0, nbs1, nbs2, nbs3, a0,a1
212 6438fCatarmC21-jun-10 at91sam9g45 21.11.3 ready mode in ready mode (exnw_mode = 11), the smc behaves differently. normally, the smc begins the access by down counting the setup and pulse counters of the read/write controlling signal. in the last cycle of the pulse phase, the resynchronized nwait signal is examined. if asserted, the smc suspends the access as shown in figure 21-28 and figure 21-29 . after deassertion, the access is completed: the hold step of the access is performed. this mode must be selected when the external de vice uses deassertion of the nwait signal to indicate its ability to complete the read or write operation. if the nwait signal is deasserted before the end of the pulse, or asserted after the end of the pulse of the controlling read/write signal, it has no impact on the access length as shown in fig- ure 21-29 . figure 21-28. nwait assertion in write access: ready mode (exnw_mode = 11) exnw_mode = 11 (ready mode) write_mode = 1 (nwe_controlled) nwe_pulse = 5 ncs_wr_pulse = 7 a [25:2] mck nwe ncs 432 1 00 0 4 5 6321110 write cycle d[31:0] nwait internally synchronized nwait signal wait state nbs0, nbs1, nbs2, nbs3, a0,a1
213 6438fCatarmC21-jun-10 at91sam9g45 figure 21-29. nwait assertion in read access: ready mode (exnw_mode = 11) exnw_mode = 11(ready mode) read_mode = 0 (ncs_controlled) nrd_pulse = 7 ncs_rd_pulse =7 a[25:2] mck ncs nrd 4 5 63200 0 1 4 5 6321 1 read cycle assertion is ignored nwait internally synchronized nwait signal wait state assertion is ignored nbs0, nbs1, nbs2, nbs3, a0,a1
214 6438fCatarmC21-jun-10 at91sam9g45 21.11.4 nwait latency and read/write timings there may be a latency between the assertion of the read/w rite controlling signal and the asser- tion of the nwait signal by the device. t he programmed pulse length of the read/write controlling signal must be at least equal to this latency plus the 2 cycles of resynchronization + 1 cycle. otherwise, the smc may enter the hold state of the access without detecting the nwait signal assertion. this is true in frozen mode as well as in ready mode. this is illustrated on fig- ure 21-30 . when exnw_mode is enabled (ready or frozen), th e user must program a pulse length of the read and write controllin g signal of at least: minimal pulse length = nwait latency + 2 resynchronization cycles + 1 cycle figure 21-30. nwait latency exnw_mode = 10 or 11 read_mode = 1 (nrd_controlled) nrd_pulse = 5 a [25:2] mck nrd 43 210 0 0 read cycle minimal pulse length nwait latency nwait intenally synchronized nwait signal wait state 2 cycle resynchronization nbs0, nbs1, nbs2, nbs3, a0,a1
215 6438fCatarmC21-jun-10 at91sam9g45 21.12 slow clock mode the smc is able to automatically apply a set of slow clock mode read/write waveforms when an internal signal driven by the power management controller is asserted because mck has been turned to a very slow clock rate (typically 32khz clock rate). in this mode, the user-pro- grammed waveforms are ignored and the slow clock mode waveforms are applied. this mode is provided so as to avoid reprogramming the user interface with appropriate waveforms at very slow clock rate. when activated, the sl ow mode is active on all chip selects. 21.12.1 slow clock mode waveforms figure 21-31 illustrates the read and write operations in slow clock mode. they are valid on all chip selects. table 21-5 indicates the value of read and write parameters in slow clock mode. figure 21-31. read/write cycles in slow clock mode a[ 25:2] ncs 1 mck nwe 1 1 nwe_cycle = 3 a [25:2] mck nrd nrd_cycle = 2 1 1 ncs slow clock mode write slow clock mode read nbs0, nbs1, nbs2, nbs3, a0,a1 nbs0, nbs1, nbs2, nbs3, a0,a1 table 21-5. read and write timing parameters in slow clock mode read parameters duration (cycles) write parameters duration (cycles) nrd_setup 1 nwe_setup 1 nrd_pulse 1 nwe_pulse 1 ncs_rd_setup 0 ncs_wr_setup 0 ncs_rd_pulse 2 ncs_wr_pulse 3 nrd_cycle 2 nwe_cycle 3
216 6438fCatarmC21-jun-10 at91sam9g45 21.12.2 switching from (to) slow clock mode to (from) normal mode when switching from slow clock mode to the nor mal mode, the current slow clock mode transfer is completed at high clock rate, with the set of slow clock mode parameters.see figure 21-32 on page 216 . the external device may not be fast enough to support such timings. figure 21-33 illustrates the recommended procedure to properly switch from one mode to the other. figure 21-32. clock rate transition occurs while the smc is performing a write operation a [25:2] ncs 1 mck nwe 1 1 nwe_cycle = 3 slow clock mode write slow clock mode internal signal from pmc 11 1 2 3 2 nwe_cycle = 7 normal mode write slow clock mode transition is detected: reload configuration wait state this write cycle finishes with the slow clock mode set of parameters after the clock rate transition slow clock mode write nbs0, nbs1, nbs2, nbs3, a0,a1
217 6438fCatarmC21-jun-10 at91sam9g45 figure 21-33. recommended procedure to switch from slow clock mo de to normal mode or from normal mode to slow clock mode a [25:2] ncs 1 mck nwe 1 1 slow clock mode write slow clock mode internal signal from pmc 2 3 2 normal mode write idle state reload configuration wait state nbs0, nbs1, nbs2, nbs3, a0,a1
218 6438fCatarmC21-jun-10 at91sam9g45 21.13 asynchronous page mode the smc supports asynchronous burst reads in page mode, providing that the page mode is enabled in the smc_mode register (pmen fiel d). the page size must be configured in the smc_mode register (ps field) to 4, 8, 16 or 32 bytes. the page defines a set of consecutive bytes into memory. a 4-byte page (resp. 8-, 16-, 32-byte page) is always aligned to 4-byte boundaries (resp. 8-, 16-, 32-byte boundaries) of memory. the msb of data address defines the address of the page in memory, the lsb of address define the address of the data in the page as detailed in table 21-6 . with page mode memory devices, the first access to one page (t pa ) takes longer than the subse- quent accesses to the page (t sa ) as shown in figure 21-34 . when in page mode, the smc enables the user to define different read timings for the first access within one page, and next accesses withi n the page. notes: 1. a denotes the address bus of the memory device 2. for 16-bit devices, the bit 0 of address is ignored. for 32-bit devices, bits [1:0] are ignored. 21.13.1 protocol and timings in page mode figure 21-34 shows the nrd and ncs timings in page mode access. figure 21-34. page mode read protocol (address msb and lsb are defined in table 21-6 ) the nrd and ncs signals are held low during all read transfers, whatever the programmed val- ues of the setup and hold timings in the us er interface may be. moreover, the nrd and ncs table 21-6. page address and data address within a page page size page address (1) data address in the page (2) 4 bytes a[25:2] a[1:0] 8 bytes a[25:3] a[2:0] 16 bytes a[25:4] a[3:0] 32 bytes a[25:5] a[4:0] a[msb] ncs mck nrd d[31:0] ncs_rd_pulse nrd_pulse nrd_pulse tsa tpa tsa a[lsb]
219 6438fCatarmC21-jun-10 at91sam9g45 timings are identical. the pulse length of the first access to the page is defined with the ncs_rd_pulse field of the smc_pulse register. the pulse length of subsequent accesses within the page are defined using the nrd_pulse parameter. in page mode, the programming of the read timings is described in table 21-7 : the smc does not check the coherency of timings. it will always apply the ncs_rd_pulse timings as page access timing (t pa ) and the nrd_pulse for accesses to the page (t sa ), even if the programmed value for t pa is shorter than the programmed value for t sa . 21.13.2 byte access type in page mode the byte access type configuration remains active in page mode. for 16-bit or 32-bit page mode devices that require byte selection signals, configure the bat field of the smc_register to 0 (byt e select access type). 21.13.3 page mode restriction the page mode is not compatible with the use of the nwait signal. using the page mode and the nwait signal may lead to unpredictable behavior. 21.13.4 sequential and non-sequential accesses if the chip select and the msb of addresses as defined in table 21-6 are identical, then the cur- rent access lies in the same page as the previous one, and no page break occurs. using this information, all data within the same page, sequential or not sequential, are accessed with a minimum access time (t sa ). figure 21-35 illustrates access to an 8-bit memory device in page mode, with 8-byte pages. access to d1 c auses a page access with a long access time (t pa ). accesses to d3 and d7, though they are not sequential accesses, only require a short access time (t sa ). if the msb of addresses are different, the smc performs the access of a new page. in the same way, if the chip select is diffe rent from the previous access, a page break occurs. if two sequen- tial accesses are made to the page mode memory , but separated by an other internal or external peripheral access, a page break occurs on the second access because the chip select of the device was deasserted between both accesses. table 21-7. programming of read timings in page mode parameter value definition read_mode x no impact ncs_rd_setup x no impact ncs_rd_pulse t pa access time of first access to the page nrd_setup x no impact nrd_pulse t sa access time of subsequent accesses in the page nrd_cycle x no impact
220 6438fCatarmC21-jun-10 at91sam9g45 figure 21-35. access to non-sequential data within the same page a [25:3] a[2], a1, a0 ncs mck nrd page address a1 a3 a7 d[7:0] ncs_rd_pulse nrd_pulse nrd_pulse d1 d3 d7
221 6438fCatarmC21-jun-10 at91sam9g45 21.14 programmable io delays the external bus interface consists of a data bus, an address bus and control signals. the simul- taneous switching outputs on these busses may lead to a peak of current in the internal and external power supply lines. in order to reduce the peak of current in such cases, additional propagation delays can be adjusted independently for pad buffers by means of configuration registers, smc_delay1-8. the additional programmable delays for each io range from 0 to 4 ns (worst case pvt). the delay can differ between ios supporting this feature. delay can be modified per programming for each io. the minimal additional delay that c an be programmed on a pad suppporting this fea- ture is 1/16 of the maximum programmable delay. when programming 0x0 in fields delay1 to de lay 8, no delay is added (reset value) and the propagation delay of the pad buffers is the inherent delay of the pad buffer. when programming 0xf in field delay1 the propagation del ay of the corresponding pad is maximal. smc_delay1, smc_delay2 allow to configur e delay on d[15:0], smc_delay1[3:0] corre- sponds to d[0] and smc_delay2[3:0] corresponds to d[8]. smc_delay3, smc_delay4 allow to configure delay on d[31:16], smc_delay3[3:0] corre- sponds to d[16] and smc_delay4[3:0] corresponds to d[24]. in case of multiplexing through the pio controller, refer to the alternate function of d[31:16]. smc_delay5, 6, 7 and 8 allow to configure delay on a[ 25 :0], smc_delay5[3:0] corresponds to a[0]. in case of multiplexing through the pio controller, refer to the alternate function of a[ 25 :0]. figure 21-36. programmable io delays delay1 d[0] programmable delay line smc d_out[0] d_in[0] delay2 d[1] programmable delay line d_out[1] d_in[1] delayx d[n] programmable delay line d_out[n] d_in[n] pio a[m] programmable delay line pio delayy a[m]
222 6438fCatarmC21-jun-10 at91sam9g45 21.15 static memory contro ller (smc) user interface the smc is programmed using the registers listed in table 21-8 . for each chip select, a set of 4 registers is used to pro- gram the parameters of the exter nal device connected on it. in table 21-8 , cs_number denotes the chip select number. 16 bytes (0x10) are required per chip select. the user must complete writing the configuration by writing any one of the smc_mode registers. table 21-8. register mapping offset register name access reset 0x10 x cs_number + 0x00 smc setup register smc_setup read-write 0x01010101 0x10 x cs_number + 0x04 smc pulse register smc_pulse read-write 0x01010101 0x10 x cs_number + 0x08 smc cycle register smc_cycle read-write 0x00030003 0x10 x cs_number + 0x0c smc mode register smc_mode read-write 0x10001000 0xc0 smc delay on i/o smc_delay1 read-write 0x00000000 0xc4 smc delay on i/o smc_delay2 read-write 0x00000000 0xc8 smc delay on i/o smc_delay3 read-write 0x00000000 0xcc smc delay on i/o smc_delay4 read-write 0x00000000 0xd0 smc delay on i/o smc_delay5 read-write 0x00000000 0xd4 smc delay on i/o smc_delay6 read-write 0x00000000 0xd8 smc delay on i/o smc_delay7 read-write 0x00000000 0xdc smc delay on i/o smc_delay8 read-write 0x00000000 0xec-0xfc reserved - - -
223 6438fCatarmC21-jun-10 at91sam9g45 21.15.1 smc setup register register name: smc_setup[0..5] addresses: 0xffffe800 [0], 0xffffe810 [1], 0xffffe 820 [2], 0xffffe830 [3], 0xffffe840 [4], 0xffffe850 [5] access type: read-write ? nwe_setup: nwe setup length the nwe signal setup length is defined as: nwe setup length = (128* nwe_setup [5] + nwe_setup[4:0]) clock cycles ? ncs_wr_setup: ncs setup length in write access in write access, the ncs signal setup length is defined as: ncs setup length = (128* ncs_wr_setup [5] + ncs_wr_setup[4:0]) clock cycles ? nrd_setup: nrd setup length the nrd signal setup length is defined in clock cycles as: nrd setup length = (128* nrd_setup[5] + nrd_setup[4:0]) clock cycles ? ncs_rd_setup: ncs setup length in read access in read access, the ncs signal setup length is defined as: ncs setup length = (128* ncs_rd_setup [5] + ncs_rd_setup[4:0]) clock cycles 31 30 29 28 27 26 25 24 C C ncs_rd_setup 23 22 21 20 19 18 17 16 C C nrd_setup 15 14 13 12 11 10 9 8 C C ncs_wr_setup 76543210 C C nwe_setup
224 6438fCatarmC21-jun-10 at91sam9g45 21.15.2 smc pulse register register name: smc_pulse[0..5] addresses: 0xffffe804 [0], 0xffffe814 [1], 0xffffe824 [2], 0xffffe834 [3], 0xffffe844 [4], 0xffffe854 [5] access type: read-write ? nwe_pulse: nwe pulse length the nwe signal pulse length is defined as: nwe pulse length = (256* nwe_pulse[6] + nwe_pulse[5:0]) clock cycles the nwe pulse length must be at least 1 clock cycle. ? ncs_wr_pulse: ncs pulse length in write access in write access, the ncs signal pulse length is defined as: ncs pulse length = (256* ncs_wr_pul se[6] + ncs_wr_pulse[5:0]) clock cycles the ncs pulse length must be at least 1 clock cycle. ? nrd_pulse: nrd pulse length in standard read access, the nrd signal pulse length is defined in clock cycles as: nrd pulse length = (256* nrd_pulse[ 6] + nrd_pulse[5:0]) clock cycles the nrd pulse length must be at least 1 clock cycle. in page mode read access, the nrd_pulse parameter defines the duration of the subsequent accesses in the page. ? ncs_rd_pulse: ncs pulse length in read access in standard read access, the ncs signal pulse length is defined as: ncs pulse length = (256* ncs_rd_pul se[6] + ncs_rd_pulse[5:0]) clock cycles the ncs pulse length must be at least 1 clock cycle. in page mode read access, the ncs_rd_pulse parameter defines the duration of the first access to one page. 31 30 29 28 27 26 25 24 C ncs_rd_pulse 23 22 21 20 19 18 17 16 C nrd_pulse 15 14 13 12 11 10 9 8 C ncs_wr_pulse 76543210 Cnwe_pulse
225 6438fCatarmC21-jun-10 at91sam9g45 21.15.3 smc cycle register register name: smc_cycle[0..5] addresses: 0xffffe808 [0], 0xffffe818 [1], 0xffffe 828 [2], 0xffffe838 [3], 0xffffe848 [4], 0xffffe858 [5] access type: read-write ? nwe_cycle: total write cycle length the total write cycle length is the total du ration in clock cycles of the write cycle. it is equal to the sum of the setup, pul se and hold steps of the nwe and ncs signals. it is defined as: write cycle length = (nwe_cycle[8:7 ]*256 + nwe_cycle[6:0]) clock cycles ? nrd_cycle: total read cycle length the total read cycle length is the total duration in clock cycles of the read cycle. it is equal to the sum of the setup, pulse and hold steps of the nrd and ncs signals. it is defined as: read cycle length = (nrd_cycle[8:7] *256 + nrd_cycle[6:0]) clock cycles 31 30 29 28 27 26 25 24 CCCCCCCnrd_cycle 23 22 21 20 19 18 17 16 nrd_cycle 15 14 13 12 11 10 9 8 CCCCCCCnwe_cycle 76543210 nwe_cycle
226 6438fCatarmC21-jun-10 at91sam9g45 21.15.4 smc mode register register name: smc_mode[0..5] addresses: 0xffffe80c [0], 0xffffe81c [1], 0xffffe82c [2], 0xffffe83c [3], 0xffffe84c [4], 0xffffe85c [5] access type: read-write ? read_mode: 1: the read operation is controlled by the nrd signal. C if tdf cycles are programmed, the external bus is marked busy after the rising edge of nrd. C if tdf optimization is enabled (tdf_mode =1), tdf wait states are inserted after the setup of nrd. 0: the read operation is controlled by the ncs signal. C if tdf cycles are programmed, the external bus is marked busy after the rising edge of ncs. C if tdf optimization is enabled (tdf_mode =1), tdf wait states are inserted after the setup of ncs. ?write_mode 1: the write operation is controlled by the nwe signal. C if tdf optimization is enabled (tdf_mode =1), tdf wa it states will be inserted after the setup of nwe. 0: the write operation is controlled by the ncs signal. C if tdf optimization is enabled (tdf_mode =1), tdf wa it states will be inserted after the setup of ncs. ? exnw_mode: nwait mode the nwait signal is used to extend the current read or writ e signal. it is only taken into account during the pulse phase of the read and writ e controlling signal. when the use of nwait is enable d, at least one cycle hold duration mu st be pro- grammed for the read and write controlling signal. ? disabled mode: the nwait input signal is ignored on the corresponding chip select. ? frozen mode: if asserted, the nwait signal freezes the current read or write cycle. after deassertion, the read/write cycle is resumed from the point where it was stopped. 31 30 29 28 27 26 25 24 CC ps CCCpmen 23 22 21 20 19 18 17 16 C C C tdf_mode tdf_cycles 15 14 13 12 11 10 9 8 CC dbw CCCbat 76543210 C C exnw_mode C C write_mode read_mode exnw_mode nwait mode 00disabled 01reserved 1 0 frozen mode 1 1 ready mode
227 6438fCatarmC21-jun-10 at91sam9g45 ? ready mode: the nwait si gnal indicates the availa bility of the external device at t he end of the pulse of the controlling read or write signal, to complete the access. if high, the access normally completes. if low, the access is extended until nwait returns high. ? bat: byte access type this field is used only if dbw defines a 16- or 32-bit data bus. ? 1: byte write access type: C write operation is controlled us ing ncs, nwr0, nwr1, nwr2, nwr3. C read operation is controlled using ncs and nrd. ? 0: byte select access type: C write operation is controlled using ncs, nwe, nbs0, nbs1, nbs2 and nbs3 C read operation is controlled using ncs, nrd, nbs0, nbs1, nbs2 and nbs3 ? dbw: data bus width ? tdf_cycles: data float time this field gives the integer number of clock cycles required by the external device to release the data after the rising edge of the read controlling signal. the smc always provide one full cycle of bus turnaround after the tdf_cycles period. the external bus cannot be used by another chip select during tdf_cycles + 1 cycles. from 0 up to 15 tdf_cycles can be set. ? tdf_mode: tdf optimization 1: tdf optimization is enabled. C the number of tdf wait states is optimized using the setup period of the next read/write access. 0: tdf optimization is disabled. C the number of tdf wait states is inserted before the next access begins. ? pmen: page mode enabled 1: asynchronous burst read in page mode is applied on the corresponding chip select. 0: standard read is applied. ? ps: page size if page mode is enabled, this field indicates the size of the page in bytes. dbw data bus width 008-bit bus 0116-bit bus 1032-bit bus 11reserved ps page size 0 0 4-byte page 0 1 8-byte page 1 0 16-byte page 1 1 32-byte page
228 6438fCatarmC21-jun-10 at91sam9g45 21.15.5 smc delay i/o register register name: smc_delay 1-8 addresses: 0xffffe8c0 [1], 0xffffe8c4 [2], 0xffffe8c8 [3], 0xffffe8cc [4], 0xffffe8d0 [5], 0xffffe8d4 [6], 0xffffe8d8 [7], 0xffffe8dc [8] access type: read-write reset value: see table 21-8 ? delay x: gives the number of elements in the delay line. 31 30 29 28 27 26 25 24 delay8 delay7 23 22 21 20 19 18 17 16 delay6 delay5 15 14 13 12 11 10 9 8 delay4 delay3 76543210 delay2 delay1
229 6438fCatarmC21-jun-10 at91sam9g45 22. ddr/sdr sdram controller (ddrsdrc) 22.1 description the ddr/sdr sdram controller (ddrsdrc) is a multiport memory controller. it comprises four slave ahb interfaces. all simultaneous accesses (four independent ahb ports) are inter- leaved to maximize memory bandwidth and minimize transaction latency due to sdram protocol . the ddrsdrc supports a read or write burst length of 8 locations which frees the command and address bus to anticipate the next command, thus reducing latency imposed by the sdram protocol and improving the sdram band width. moreover it keeps track of the active row in each bank, thus maximizing sdram perfo rmance, e.g., the application may be placed in one bank and data in the other banks. so as to optimize performance, it is advisable to avoid accessing different rows in the same bank. the ddrsdrc supports a cas latency of 2 or 3 and optimizes the read access depending on the frequency. the features of self refresh, power-down and deep power-down modes minimize the consump- tion of the sdram device. the ddrsdrc user inte rface is compliant wit h arm advanced perip heral bus (apb rev2). note: the term sdram device regroups sdr-sd ram, mobile sdr-sdram, mobile ddr1- sdram and ddr2-sdram devices.
230 6438fCatarmC21-jun-10 at91sam9g45 22.2 ddrsdrc module diagram figure 22-1. ddrsdrc module diagram ddrsdrc is partitioned in two blocks (see figure 22-1 ): ? an interconnect-matrix that manages concurrent accesses on the ahb bus between four ahb masters and integrates an arbiter. ? a controller that translates ahb requests (read/write) in the sdram protocol. memory controller finite s t a te m a chine s dram s ign a l m a n a gement addr, dqm d a t a a s ynchrono us timing refre s h m a n a gement ddr- s dr device s power m a n a gement dq s r as ,c as ,we cke clk/nclk odt ddr- s dr controller interconnect m a trix inp u t s t a ge inp u t s t a ge inp u t s t a ge o u tp u t s t a ge ar b iter apb ahb s l a ve interf a ce 0 ahb s l a ve interf a ce 1 ahb s l a ve interf a ce 2 ahb s l a ve interf a ce 3 inp u t s t a ge interf a ce apb
231 6438fCatarmC21-jun-10 at91sam9g45 22.3 product dependencies the addresses given are for example purposes on ly. the real address depends on implementa- tion in the product. 22.3.1 sdr-sdram initialization the initialization sequence is generated by so ftware. the sdr-sdram devices are initialized by the following sequence: 1. program the memory device type into the memory device register (see section 22.7.8 on page 271 ). 2. program the features of the sdr-sdram device into the timing register (asynchro- nous timing (trc, tras, etc.)), and into the configuration register (number of columns, rows, banks, cas latency) (see section 22.7.3 on page 262 , section 22.7.4 on page 265 and section 22.7.5 on page 267 ). 3. for low-power sdram, temperature-compensated self refresh (tcsr), drive strength (ds) and partial array self refresh (pasr) must be set in the low-power register (see section 22.7.7 on page 269 ). a minimum pause of 200 s is provi ded to precede any signal toggle. 4. a nop command is issued to the sdr-sdram. program nop command into mode register, the application must set mode to 1 in the mode register (see section 22.7.1 on page 260 ). perform a write access to any sdr-sdram address to acknowledge this command. now the clock which dr ives sdr-sdram device is enabled. 5. an all banks precharge command is issued to the sdr-sdram. program all banks precharge command into mode register, the application must set mode to 2 in the mode register (see section 22.7.1 on page 260 ). perform a write access to any sdr- sdram address to acknowledge this command. 6. eight auto-refresh (cbr) cycles are provided. program the auto refresh command (cbr) into mode register, the application must set mode to 4 in the mode register (see section 22.7.1 on page 260 ).performs a write access to any sdr-sdram loca- tion eight times to acknowledge these commands. 7. a mode register set (mrs) cycle is issued to program the parameters of the sdr- sdram devices, in particular cas latency and burst length. the application must set mode to 3 in the mode register (see section 22.7.1 on page 260 ) and perform a write access to the sdr-sdram to acknowledge this command. the write address must be chosen so that ba[1:0] are set to 0. for example, with a 16-bit 128 mb sdr-sdram (12 rows, 9 columns, 4 banks) bank address, the sdram write access should be done at the address 0x20000000. note: this address is for example purposes only. t he real address is dependent on implementation in the product. 8. for low-power sdr-sdram initialization, an extended mode register set (emrs) cycle is issued to program the sdr-sdram parameters (tcsr, pasr, ds). the appli- cation must set mode to 5 in the mode register (see section 22.7.1 on page 260 ) and perform a write access to the sdr-sdram to acknowledge this command. the write address must be chosen so that ba[1] is set to 1 and ba[0] is set to 0. for example, with a 16-bit 128 mb sdram, (12 rows, 9 columns, 4 banks) bank address the sdram write access should be done at the address 0x20800000. 9. the application must go into normal mode, setting mode to 0 in the mode register (see section 22.7.1 on page 260 ) and perform a write access at any location in the sdram to acknowledge this command.
232 6438fCatarmC21-jun-10 at91sam9g45 10. write the refresh rate into the count field in the ddrsdrc refresh timer register (see page 261 ). (refresh rate = delay between re fresh cycles). the sdr-sdram device requires a refresh every 15.625 s or 7.81 s. with a 100 mhz frequency, the refresh timer count register must to be set with (15.625 /100 mhz) = 1562 i.e. 0x061a or (7.81 /100 mhz) = 781 i.e. 0x030d after initialization, the sdr-s dram device is fully functional. 22.3.2 low-power ddr1-sdram initialization the initialization sequence is generated by software. the low-power ddr1-sdram devices are initialized by the following sequence: 1. program the memory device type into the memory device register (see section 22.7.8 on page 271 ). 2. program the features of the low-power ddr1-sdram device into the configuration register: asynchronous timing (trc, tras, etc.), number of columns, rows, banks, cas latency. see section 22.7.3 on page 262 , section 22.7.4 on page 265 and section 22.7.5 on page 267 . 3. program temperature compensated self refresh (tcr), partial array self refresh (pasr) and drive strength (ds) into the low-power register. see section 22.7.7 on page 269 . 4. an nop command will be issued to the low-power ddr1-sdram. program nop com- mand into the mode register, the application must set mode to 1 in the mode register (see section 22.7.1 on page 260 ). perform a write access to any ddr1-sdram address to acknowle dge this command. now clocks which drive ddr1-sdram device are enabled. a minimum pause of 200 s will be provid ed to precede any signal toggle. 5. an all banks precharge command is issued to the low-power ddr1-sdram. program all banks precharge command into the mode register, the application must set mode to 2 in the mode register (see section 22.7.1 on page 260 ). perform a write access to any low-power ddr1-sdram address to acknowledge this command 6. two auto-refresh (cbr) cycles are provid ed. program the auto refresh command (cbr) into the mode register, the application must set mode to 4 in the mode register (see section 22.7.1 on page 260 ). perform a write access to any low-power ddr1- sdram location twice to acknowledge these commands. 7. an extended mode register set (emrs) cycle is issued to program the low-power ddr1-sdram parameters (tcsr, pasr, ds). the application must set mode to 5 in the mode register (see section 22.7.1 on page 260 ) and perform a write access to the sdram to acknowledge this command. the write address must be chosen so that ba[1] is set to 1 ba[0] is set to 0. for ex ample, with a 16-bit 128 mb sdram (12 rows, 9 columns, 4 banks) bank address, the low-power ddr1-sdram write access should be done at the address 0x20800000. note: this address is for example purposes only. t he real address is dependent on implementation in the product. 8. a mode register set (mrs) cycle is issued to program the parameters of the low-power ddr1-sdram devices, in particular cas late ncy, burst length. the application must set mode to 3 in the mode register (see section 22.7.1 on page 260 ) and perform a write access to the low-power ddr1-sdram to acknowledge this command. the write address must be chosen so that ba[1:0] bits are set to 0. for example, with a 16-bit 128 mb low-power ddr1-sdram (12 rows, 9 columns, 4 banks) bank address, the sdram write access should be done at the address 0x20000000
233 6438fCatarmC21-jun-10 at91sam9g45 9. the application must go into normal mode, setting mode to 0 in the mode register (see section 22.7.1 on page 260 ) and performing a write access at any location in the low- power ddr1-sdram to acknowledge this command. 10. perform a write access to an y low-power ddr1 -sdram address. 11. write the refresh rate into the count field in the ddrsdrc refresh timer register (see page 261 ). (refresh rate = delay between refresh cycles). the low-power ddr1- sdram device requires a refresh every 15.625 s or 7.81 s. with a 100 mhz fre- quency, the refresh timer count register must to be set with (15.625 /100 mhz) = 1562 i.e. 0x061a or (7.81 /100 mhz) = 781 i.e. 0x030d 12. after initialization, the low-power ddr1-sdram de vice is fully functional. 22.3.3 ddr2-sdram initialization the initialization sequence is generated by so ftware. the ddr2-sdram de vices are initialized by the following sequence: 1. program the memory device type into the memory device register (see section 22.7.8 on page 271 ). 2. program the features of ddr2-sdram device into the timing register (asynchronous timing (trc, tras, etc.)), and into the configuration register (number of columns, rows, banks, cas latency and output drive strength) (see section 22.7.3 on page 262 , section 22.7.4 on page 265 and section 22.7.5 on page 267 ). 3. an nop command is issued to the ddr2-sdram. program the nop command into the mode register, the application must set mode to 1 in the mode register (see sec- tion 22.7.1 on page 260 ). perform a write access to any ddr2-sdram address to acknowledge this command . now clocks which drive ddr2-sdram device are enabled. a minimum pause of 200 s is provi ded to precede any signal toggle. 4. an nop command is issued to the ddr2-sdram. program the nop command into the mode register, the application must set mode to 1 in the mode register (see sec- tion 22.7.1 on page 260 ). perform a write access to any ddr2-sdram address to acknowledge this command. now cke is driven high. 5. an all banks precharge command is issued to the ddr2-sdram. program all banks precharge command into the mode register, the application must set mode to 2 in the mode register (see section 22.7.1 on page 260 ). perform a write access to any ddr2- sdram address to acknowledge this command 6. an extended mode register set (emrs2) cycle is issued to chose between commer- cial or high temperature operations. the application must set mode to 5 in the mode register (see section 22.7.1 on page 260 ) and perform a write access to the ddr2- sdram to acknowledge this command. the write address must be chosen so that ba[1] is set to 1 and ba[0] is set to 0. for example, with a 16-bit 128 mb ddr2- sdram (12 rows, 9 columns, 4 banks) bank address, the ddr2-sdram write access should be done at the address 0x20800000. note: this address is for example purposes only. t he real address is dependent on implementation in the product. 7. an extended mode register set (emrs3) cycle is issued to set all registers to 0. the application must set mode to 5 in the mode register (see section 22.7.1 on page 260 ) and perform a write access to the ddr2-sdram to acknowledge this command. the write address must be chosen so that ba[1] is set to 1 and ba[0] is set to 1. for exam- ple, with a 16-bit 128 mb ddr2-sdram (12 rows, 9 columns, 4 banks) bank address, the ddr2-sdram write access should be done at the address 0x20c00000.
234 6438fCatarmC21-jun-10 at91sam9g45 8. an extended mode register set (emrs1) cycle is issued to enable dll. the applica- tion must set mode to 5 in the mode register (see section 22.7.1 on page 260 ) and perform a write access to the ddr2-sdram to acknowledge this command. the write address must be chosen so that ba[1] is set to 0 and ba[0] is set to 1. for example, with a 16-bit 128 mb ddr2-sdram (12 rows, 9 columns, 4 banks) bank address, the ddr2-sdram write access should be done at the address 0x20400000. an additional 200 cycles of clock are required for locking dll 9. program dll field into the configuration register (see section 22.7.3 on page 262 ) to high (enable dll reset). 10. a mode register set (mrs) cycle is issued to reset dll. the application must set mode to 3 in the mode register (see section 22.7.1 on page 260 ) and perform a write access to the ddr2-sdram to acknowledge this command. the write address must be chosen so that ba[1:0] bits are set to 0. for example, with a 16-bit 128 mb ddr2- sdram (12 rows, 9 columns, 4 banks) bank address, the sdram write access should be done at the address 0x20000000. 11. an all banks precharge command is issued to the ddr2-sdram. program all banks precharge command into the mode register, the application must set mode to 2 in the mode register (see section 22.7.1 on page 260 ). perform a write access to any ddr2- sdram address to acknowledge this command 12. two auto-refresh (cbr) cycl es are provided. program the auto refresh command (cbr) into the mode register, the application must set mode to 4 in the mode register (see section 22.7.1 on page 260 ). performs a write access to any ddr2-sdram loca- tion twice to acknowledge these commands. 13. program dll field into the configuration register (see section 22.7.3 on page 262 ) to low (disable dll reset). 14. a mode register set (mrs) cycle is issued to program the parameters of the ddr2- sdram devices, in particular cas latency, burst length and to disable dll reset. the application must set mode to 3 in the mode register (see section 22.7.1 on page 260 ) and perform a write access to the ddr2-sdram to acknowledge this command. the write address must be chosen so that ba[1:0] are set to 0. for example, with a 16-bit 128 mb sdram (12 rows, 9 columns, 4 banks) bank address, the sdram write access should be done at the address 0x20000000 15. program ocd field into the configuration register (see section 22.7.3 on page 262 ) to high (ocd calibration default). 16. an extended mode register set (emrs1) c ycle is issued to ocd default value. the application must set mode to 5 in the mode register (see section 22.7.1 on page 260 ) and perform a write access to the ddr2-sdram to acknowledge this command. the write address must be chosen so that ba[1] is set to 0 and ba[0] is set to 1. for exam- ple, with a 16-bit 128 mb ddr2-sdram (12 rows, 9 columns, 4 banks) bank address, the ddr2-sdram write access should be done at the address 0x20400000. 17. program ocd field into the configuration register (see section 22.7.3 on page 262 ) to low (ocd calibration mode exit). 18. an extended mode register set (emrs1) cycle is issued to enable ocd exit. the application must set mode to 5 in the mode register (see section 22.7.1 on page 260 ) and perform a write access to the ddr2-sdram to acknowledge this command. the write address must be chosen so that ba[1] is set to 0 and ba[0] is set to 1. for exam- ple, with a 16-bit 128 mb ddr2-sdram (12 rows, 9 columns, 4 banks) bank address, the ddr2-sdram write access should be done at the address 0x20400000.
235 6438fCatarmC21-jun-10 at91sam9g45 19. a mode normal command is provided. program the normal mode into mode register (see section 22.7.1 on page 260 ). perform a write access to any ddr2-sdram address to acknowledge this command. 20. perform a write access to any ddr2-sdram address. 21. write the refresh rate into the count field in the refresh timer register (see page 261 ). (refresh rate = delay between refresh cycles). the ddr2-sdram device requires a refresh every 15.625 s or 7.81 s. with a 133 mhz frequency, the refresh timer count register must to be set with (15.625 /133 mhz) = 1175 i.e. 0x0497 or (7.81 /133 mhz) = 587 i.e. 0x024b. after initialization, the ddr2-sdra m devices are fully functional.
236 6438fCatarmC21-jun-10 at91sam9g45 22.4 functional description 22.4.1 sdram controller write cycle the ddrsdrc allows burst access or single access in normal mode (mode = 000). whatever the access type, the ddrsdrc k eeps track of the active row in each bank, thus maximizing performance. the sdram device is programmed with a burst length equal to 8. this determines the length of a sequential data input by the write command that is set to 8. the latency from write command to data input is fixed to 1 in the case of ddr-sdram devices. in the case of sdr-sdram devices, there is no latency from write command to data input. to initiate a single access, the ddrsdrc che cks if the page access is already open. if row/bank addresses match with the previous row/bank addresses, the controller generates a write command. if the bank addresses are not identical or if bank addresses are identical but the row addresses are not identical, the controller generates a precharge command, activates the new row and initiates a write co mmand. to comply with sdram timing parameters, additional clock cycles are inserted between precharge/active (t rp) comm ands and active/write (t rcd) command. as the burst length is fixed to 8, in the case of single access, it has to stop the burst, otherwise seven invalid values may be written. in the case of sdr-sdram devices, a burst stop command is generated to interrupt the write operation. in the case of ddr-sdram devices, burst stop command is not supported for the burst write operation. in order to then interrupt the write operation, dm must be set to 1 to mask invalid data (see figure 22-2 on page 237 and figure 22-5 on page 238 ) and dqs must continue to toggle. to initiate a burst access, the ddrsdrc uses the transfer type signal pr ovided by the master requesting the access. if the next access is a sequential write access, writing to the sdram device is carried out. if the next access is a write non-sequential access, then an automatic access break is inserted, the ddrsdrc generates a precharge command, activates the new row and initiates a write command. to comply with sdram timing parameters, additional clock cycles are inserted between precharge/acti ve (trp) commands and active/write (trcd) commands. for a definition of timing parameters, refer to section 22.7.4 ddrsdrc timing 0 parameter register on page 265 . write accesses to the sdram devices are burst oriented and the burst length is programmed to 8. it determines the maximum number of column locations that can be accessed for a given write command. when the write command is issued, 8 columns are selected. all accesses for that burst take place within these eight columns, thus the burst wraps within these 8 columns if a boundary is reached. these 8 columns are selected by addr[13:3]. addr[2:0] is used to select the starting location within the block. in the case of incrementing burst (incr/incr 4/incr8/incr16), the addresses can cross the 16-byte boundary of the sdram device. for example, in th e case of ddr-sdram devices, when a transfer (incr4) starts at address 0x0c , the next access is 0x10, but since the burst length is programmed to 8, the next access is at 0x00. since the boundary is reached, the burst is wrapping. the ddrsdrc takes th is feature of the sdram device into account. in the case of transfer starting at address 0x04/0x08/0x0c (ddr-sdram devices) or starting at address 0x10/0x14/0x18/0x1c, two write commands are issued to avoid to wrap when the boundary is reached. the last write command is subject to dm input logic level. if dm is registered high, the corresponding data input is ignored and write access is not done. this avoi ds additional writing being done.
237 6438fCatarmC21-jun-10 at91sam9g45 figure 22-2. single write access, row closed, low-power ddr1-sdram device figure 22-3. single write access, row closed, ddr2-sdram device sdclk a[12:0] command ba[1:0] 0 row a col a nop prchg nop act nop write nop 0 dm[1:0] 0 3 trp = 2 trcd = 2 dqs[1:0] d[15:0] db da 3 sdclk a[12:0] command ba[1:0] 0 row a col a nop prchg nop act nop write nop 0 dm[1:0] 0 3 trp = 2 trcd = 2 dqs[1:0] d[15:0] db da 3
238 6438fCatarmC21-jun-10 at91sam9g45 figure 22-4. single write access, row closed, sdr-sdram device figure 22-5. burst write access, row closed, low-power ddr1-sdram device row a col a 3 0 3 nop prchg nop act nop write nop bst sdclk a[12:0] command ba[1:0] 0 0 dm[1:0] trp = 2 d[31:0] dadb trcd = 2 trp = 2 trcd = 2 sdclk row a col a a[12:0] nop prchg nop act nop write nop command 0 ba[1:0] dqs[1:0] da db dc dd de df dg dh d [15:0] 3 0 3 dm[1:0]
239 6438fCatarmC21-jun-10 at91sam9g45 figure 22-6. burst write access, row closed, ddr2-sdram device figure 22-7. burst write access, row closed, sdr-sdram device a write command can be followed by a read command. to avoid breaking the current write burst, twtr/twrd (bl/2 + 2 = 6 cycles) should be met. see figure 22-8 on page 240 . trp = 2 trcd = 2 sdclk row a col a a[12:0] nop prchg nop act nop write nop command 0 ba[1:0] dqs[1:0] da db dc dd de df dg dh d [15:0] 3 0 3 dm[1:0] row a col a nop prchg nop act nop write nop 0 da db dc dd de df dg dhs f 0 f trp trcd bst nop sdclk a[12:0] command ba[1:0] d[31:0] dm[3:0]
240 6438fCatarmC21-jun-10 at91sam9g45 figure 22-8. write command followed by a read command without burst write interrupt, low-power ddr1-sdram device in the case of a single write access, write operation should be interrupted by a read access but dm must be input 1 cycle prior to the read command to avoid writing invalid data. see figure 22- 9 on page 240 . figure 22-9. single write access followed by a read access low-power ddr1-sdram devices twrd = bl/2 +2 = 8/2 +2 = 6 twr = 1 sdclk col a col a a[12:0] nop write nop read bst nop command 0 ba[1:0] dqs[1:0] dc dd de df dg dh da db da db d[15:0] 3 0 3 dm[1:0] row a col a nop prchg nop act nop write nop read bst nop 0 data masked sdclk a[12:0] command ba[1:0] dqs[1:0] da db da db d[15:0] 3 0 3 dm[1:0]
241 6438fCatarmC21-jun-10 at91sam9g45 figure 22-10. single write access followed by a read access, ddr2 -sdram device 22.4.2 sdram controller read cycle the ddrsdrc allows burst access or single access in normal mode (mode =000). whatever access type, the ddrsdrc keeps track of the active row in each bank, thus maximizing perfor- mance of the ddrsdrc. the sdram devices are programmed with a burst length equal to 8 which determines the length of a sequential data output by the read command that is set to 8. the latency from read com- mand to data output is equal to 2 or 3. this value is programmed during the initialization phase (see section 22.3.1 sdr-sdram initialization on page 231 ). to initiate a single access, the ddrsdrc che cks if the page access is already open. if row/bank addresses match with the previous row/bank addresses, the controller generates a read command. if the bank addresses are not identi cal or if bank addresses are identical but the row addresses are not identical, the controller generates a precharge command, activates the new row and initiates a read command. to comply with sdram timing parameters, additional clock cycles are inserted between precharge/ active (trp) commands and active/read (trcd) command. after a read command, additional wait states are generated to comply with cas latency. the ddrsdrc supports a cas latency of two, two and ha lf, and three (2 or 3 clocks delay). as the burst length is fixed to 8, in the case of single access or burst access inferior to 8 data requests, it has to stop the burst otherwise seven or x values could be read. burst stop command (bst) is used to stop output during a burst read. to initiate a burst access, the ddrsdrc checks th e transfer type signal . if the next accesses are sequential read acce sses, reading to the sdram device is carried out. if the next access is a read non-sequential access, then an automatic page break can be inserted. if the bank addresses are not identical or if bank addresses are identical but the row addresses are not identical, the controller generates a precharge command, activates the new row and initiates a read command. in the case where the page access is already open, a read command is generated. row a col a nop prchg nop act nop write nop read nop 0 data masked sdclk a[12:0] command ba[1:0] dqs[1:0] da db da db d[15:0] 3 0 3 dm[1:0] twtr
242 6438fCatarmC21-jun-10 at91sam9g45 to comply with sdram timing parameters, addit ional clock cycles are inserted between pre- charge/active (trp) commands and active/r ead (trcd) commands. the ddrsdrc supports a cas latency of two, two and half, and three (2 or 3 clocks delay). during this delay, the controller uses internal signals to anticipate the next access and improve the performance of the control- ler. depending on the latency(2/3), the ddrsdrc anticipates 2 or 3 read accesses. in the case of burst of specified length, accesses are not anticipated, but if the burst is broken (border, busy mode, etc.), the next access is treated as an incrementing burst of unspecified length, and in function of the latency(2/3), the ddrsdrc anticipates 2 or 3 read accesses. for a definition of timing parameters, refer to section 22.7.3 ddrsdrc configuration register on page 262 . read accesses to the sdram are burst oriented and the burst length is programmed to 8. it determines the maximum number of column locations that can be accessed for a given read command. when the read command is issued, 8 columns are selected. all accesses for that burst take place within these eight columns, me aning that the burst wraps within these 8 col- umns if the boundary is reached. these 8 column s are selected by addr[13:3]; addr[2:0] is used to select the starting location within the block. in the case of incrementing burst (incr/incr 4/incr8/incr16), the addresses can cross the 16-byte boundary of the sdram device. for example, when a transfer (incr4) starts at address 0x0c, the next access is 0x10, but since the burst length is programmed to 8, the next access is 0x00. since the boundary is reach ed, the burst wraps. the ddrsdrc takes into account this feature of the sdram device. in th e case of ddr-sdram devices, transfers start at address 0x04/0x08/0x0c. in the case of sd r-sdram devices, transfers start at address 0x14/0x18/0x1c. two read commands are is sued to avoid wrapping when the boundary is reached. the last re ad command may generate ad ditional reading (1 read cmd = 4 ddr words or 1 read cmd = 8 sdr words). to avoid additional reading, it is possible to use the burst stop command to truncate the read burst and to decrease power consumption.
243 6438fCatarmC21-jun-10 at91sam9g45 figure 22-11. single read access, row close, laten cy = 2,low-power ddr1-sdram device figure 22-12. single read access, row close, latency = 3, ddr2-sdram device trp trcd latency = 2 sdclk row a col a a[12:0] nop prchg nop act nop read bst nop command 0 ba[1:0] dqs[1] dqs[0] da db d[15:0] 3 dm[1:0] trp trcd latency = 2 sdclk row a col a a[12:0] nop prchg nop act nop read command 0 ba[1:0] dqs[1] dqs[0] da db d[15:0] 3 dm[1:0]
244 6438fCatarmC21-jun-10 at91sam9g45 figure 22-13. single read access, row close, latency = 2, sdr-sdram device figure 22-14. burst read access, latency = 2, low-power ddr1-s dram devices row a col a nop prchg nop act nop read bst nop 0 trp trcd latency = 2 sdclk a[12:0] command ba[1:0] dadb d[31:0] 3 dm[3:0] col a nop read nop 0 latency = 2 sdclk a[12:0] command ba[1:0] dqs[1:0] da db dc dd de df dg dh d[15:0] 3 dm[1:0]
245 6438fCatarmC21-jun-10 at91sam9g45 figure 22-15. burst read access, latency = 3, ddr2-sdram devices figure 22-16. burst read access, latency = 2, sdr-sdram devices col a nop read nop 0 latency = 3 sdclk a[12:0] command ba[1:0] dqs[1:0] da db dc dd de df dg dh d[15:0] 3 dm[1:0] latency = 2 sdclk col a a[12:0] nop read nop bst nop command 0 ba[1:0] dadb dcdd dedf dg dh d[31:0] f dm[3:0] dqs[1:0]
246 6438fCatarmC21-jun-10 at91sam9g45 22.4.3 refresh (auto-refresh command) an auto-refresh command is used to refresh the ddrsdrc. refresh addresses are generated internally by the sdram device and incremented after each auto-refresh automatically. the ddrsdrc generates these auto-refresh commands periodically. a timer is loaded with the value in the register ddrsdrc_tr that indicates the number of clock cycles between refresh cycles. when the ddrsdrc initiates a refresh of an sdram device, internal memory accesses are not delayed. however, if the cpu tries to access the sdram device, the slave indicates that the device is busy. a request of refresh does not interrupt a burst transfer in progress. 22.4.4 power management 22.4.4.1 self refresh mode this mode is activated by setting low-powe r command bits [lpcb] to 01 in the ddrsdrc_lpr register self refresh mode is used to reduce power consumption, i.e., when no access to the sdram device is possible. in this case, power consumption is very low. in self refresh mode, the sdram device retains data without external clocking and provides its own internal clocking, thus performing its own auto-refresh cycles. a ll the inputs to the sdram device become dont care except cke, which remains low. as soon as the sdram device is selected, the ddrs- drc provides a sequence of commands and exits self refresh mode. the ddrsdrc re-enables self refresh mode as soon as the sdram device is not selected. it is possible to define when self refresh mode will be enabled by setting the register lpr (see sec- tion 22.7.7 ddrsdrc low-po wer register on page 269 ), timeout command bit: ? 00 = self refresh mode is enabled as soon as the sdram device is not selected ? 01 = self refresh mode is enabled 64 clock cycles after completion of the last access ? 10 = self refresh mode is enabled 128 clock cycles after completion of the last access as soon as the sdram device is no longe r selected, precharge all banks command is generated followed by a self-refrefsh co mmand. if, between these two commands an sdram access is detected, self-refrefsh command will be replaced by an auto- refresh command. according to the applica tion, more auto-refresh commands will be performed when the self refresh mode is enabled during the application. this controller also interfaces low-power sd ram. these devices add a new feature: a single quarter, one half quarter or all banks of the sdram array can be enabled in self refresh mode. disabled banks will be not refreshed in self refresh mode. this feat ure permits to reduce the self refresh current. the extended mode register controls this feature, it includes temperature com- pensated self refresh (tscr), partial array self refresh (pasr) parameters and drive strength (ds). these parameters are set during the initialization phase. after initialization, as soon as pasr/ds/tcsr fields are modified, the extended mode r egister in the memory of the external device is accessed automatica lly and pasr/ds/tcsr bits are updated before entry into self refresh mode if ddrsdrc does not share an external bus with another controller or during a refresh command, and a pending read or write access, if ddrsdrc does share an external bus with another controller. this type of update is a function of the upd_mr bit (see section 22.7.7 ddrsdrc low- power register on page 269 ). the low-power sdr-sdram must remain in self refresh mode for a minimum period of tras periods and may remain in self refresh mode for an indefinite period. (see figure 22-17 )
247 6438fCatarmC21-jun-10 at91sam9g45 the low-power ddr-sdram must remain in self refresh mode for a minimum of trfc periods and may remain in self refresh mode for an indefinite period. the ddr2-sdram must remain in self refres h mode for a minimum of tcke periods and may remain in self refresh m ode for an indefinite period. figure 22-17. self refresh mode entry, timeout = 0 figure 22-18. self refresh mode entry, timeout = 1 or 2 nop read bst nop prchg nop arfsh nop 0 trp enter self refresh mode sdclk a[12:0] command cke ba[1:0] dqs[0:1] da db d[15:0] 3 dm[1:0] nop read bst nop 0 da db 64 or 128 wait states 3 prchg nop arfsh nop trp enter self refresh mode sdclk a[12:0] command cke ba[1:0] dqs[1:0] d[15:0] dm[1:0]
248 6438fCatarmC21-jun-10 at91sam9g45 figure 22-19. self refresh mode exit figure 22-20. self refresh and automatic update nop valid nop 0 txnrd/txsrd (ddr device) txsr (low-power ddr device) txsr (low-power sdr, sdr-sdram device) exit self refresh mode clock must be stable before exiting self refresh mode sdclk a[12:0] command cke ba[1:0] dqs[1:0] dadb d[15:0] 3 dm[1:0] nop nop prchg mr s arf s h nop 0 tmrd enter s elf refre s h mode s dclk a[12:0] command cke ba[1:0] 2 nop upd a te extended mode regi s ter trp p as r-tcr-d s
249 6438fCatarmC21-jun-10 at91sam9g45 figure 22-21. automatic update during auto-r efresh command and sdram access 22.4.4.2 power-down mode this mode is activated by setting the low-power command bits [lpcb] to 10. power-down mode is used when no access to the sdram device is possible. in this mode, power consumption is greater than in self refresh mode. this state is similar to normal mode (no low-power mode/no self refresh mode), but the cke pin is low and the input and output buffers are deactivated as soon the sdram device is no longer accessible. in contrast to self refresh mode, the sdram device cannot remain in low-power mode longer than the refresh period (64 ms). as no auto-refresh oper ations are performed in this mode, the ddrsdrc carries out the refresh operation. in order to exit low-power mode, a nop command is required in the case of low-power sdr-sdram and sdr-sdram devices. in the case of low-power ddr-sdram devices, the controller generates a nop command during a delay of at least txp. in addition, low-power ddr-sdram and ddr2-sdram must remain in power-down mode for a minimum period of tcke periods. the exit procedure is faster than in self refresh mode. see figure 22-22 on page 250 . the ddrsdrc returns to power-down mode as soon as the sdram device is not selected. it is possible to define when power-down mode is enabled by setting the register lpr, timeout com- mand bit. ? 00 = power-down mode is enabled as soon as the sdram device is not selected ? 01 = power-down mode is enabled 64 clock cycles after completion of the last access ? 10 = power-down mode is enabled 128 clock cycles after co mpletion of th e last access nop nop prchall mr s arf s h nop 0 trfc s dclk a[12:0] command cke ba[1:0] 2 nop upd a te extended mode regi s ter trp p as r-tcr-d s act 0 tmrd
250 6438fCatarmC21-jun-10 at91sam9g45 figure 22-22. power-down entry/exit, timeout = 0 22.4.4.3 deep power-down mode the deep power-down mode is a new feature of the low-power sdram. when this mode is activated, all internal voltage generators inside the device are stopped and all data is lost. this mode is activated by setting the low-power command bits [lpcb] to 11. when this mode is enabled, the ddrsdrc leaves normal mode (mode == 000) and the controller is frozen. to exit deep power-down mode, the low-power bits (lpcb) must be set to 00, an initialization sequence must be generated by software. see section 22.3.2 low-power ddr1-sdram ini- tialization on page 232 . figure 22-23. deep power-down mode entry entry power down mode exit power down mode sdclk a[12:0] read bst nop read command cke 0 ba[1:0] dqs[1:0] da db d[15:0] 3 dm[1:0] nop read bst nop prchg nop deepower nop 0 trp enter deep power-down mode sdclk a[12:0] command cke ba[1:0] dqs[1:0] da db d[15:0] 3 dm[1:0]
251 6438fCatarmC21-jun-10 at91sam9g45 22.4.4.4 reset mode the reset mode is a feature of the ddr2-sdram. this mode is activated by setting the low- power command bits (lpcb) to 11 and the clock frozen command bit (clk_fr) to 1. when this mode is enabled, the ddrsdrc leaves normal mode (mode == 000) and the control- ler is frozen. before enabling this mode, the end user must assume there is not an access in progress. to exit reset mode, the low-power command bits (lpcb) must be set to 00, clock frozen com- mand bit (clk_fr) set to 0 and an initialization sequence must be generated by software. see, section 22.3.3 ddr2-sdram initialization on page 233 .
252 6438fCatarmC21-jun-10 at91sam9g45 22.4.5 multi-port functionality the sdram protocol imposes a check of timings prior to performing a read or a write access, thus decreasing the performance of systems. an access to sdram is performed if banks and rows are open (or active). to activate a row in a particular bank, it has to de-active the last open row and open the new row. two sdram commands must be performed to open a bank: pre- charge and active command with respect to trp timing. before performing a read or write command, trcd timing must checked. this operation represents a significative loss. (see figure 22-24 ). figure 22-24. trp and trcd timings the multi-port controller has been designed to mask these timings and thus improve the band- width of the system. ddrsdrc is a multi-port controller since four masters can simultaneously reach the controller. this feature improves the bandwidth of the system because it can detect four requests on the ahb slave inputs and thus anticipate the commands that follow, precharge and active commands in bank x during current access in bank y. this allows trp and trcd timings to be masked (see figure 22-25 ). in the best case, all accesses are done as if the banks and rows were already open. the best condition is met when the four masters work in different banks. in the case of four simultaneous read accesses, when the four banks and associated rows are open, the controller reads with a continuous flow and masks the cas latency for each different access. to allow a continuous flow, the read command must be set at 2 or 3 cycles (cas latency) before the end of current access. this requires that the scheme of arbitration changes since the round-robin arbitration cannot be respected. if the controller anticipates a read access, and thus before the end of current access a master with a high priority arises, then this master will not serviced. the arbitration mechanism reduces latency when conflicts occur, i.e., when two or more masters try to access the sdram device at the same time. nop prchg nop act nop read bst nop 0 3 trp trcd latency =2 4 cycles before performing a read command sdclk a[12:0] command ba[1:0] dqs[1:0] d[15:0] dm1:0] da db
253 6438fCatarmC21-jun-10 at91sam9g45 the arbitration type is round-robin arbitration. th is algorithm dispatches the requests from differ- ent masters to the sdram device in a round-robin manner. if two or more master requests arise at the same time, the master with the lowest num ber is serviced first, then the others are ser- viced in a round-robin manner. to avoid burst breaking and to provide the maximum throughput for the sdram device, arbitration may only take place during the following cycles: 1. idle cycles: when no master is connected to the sdram device. 2. single cycles: when a slave is currently doing a single access. 3. end of burst cycles: when the current cycle is the last cycle of a burst transfer. for bursts of defined length, predicted end of burst matches the size of the transfer. for bursts of undefined length, predicted end of burst is generated at the end of each four beat boundary inside the incr transfer. 4. anticipated access: when an anticipate re ad access is done while current access is not complete, the arbitration scheme can be changed if the anticipated access is not the next access serviced by the arbitration scheme. figure 22-25. anticipate precharge/active command in bank 2 during read access in bank 1 nop read nop 0 nop prech act read 1 1 2 anticipate command, precharge/active bank 2 trp read access in bank 1 sdclk a[12:0] command ba[1:0] dqs[1:0] da db dc dd de df dg dh di dj dk dl d[15:0] 3 dm1:0]
254 6438fCatarmC21-jun-10 at91sam9g45 22.4.6 write protected registers to prevent any single software error that ma y corrupt ddrsdrc behavior, the registers listed below can be write-protected by setting the wpen bit in the ddrsdrc write protect mode register (ddrsdrc_wpmr). if a write access in a write-pr otected register is detected, t hen the wpvs flag in the ddrsdrc write protect status register (ddrsdrc_wpsr) is set and the field wpvsrc indicates in which register the write access has been attempted. the wpvs flag is automatically reset after read ing the ddrsdrc write protect status register (ddrsdrc_wpsr). following is a list of the write protected registers: ? ddrsdrc mode register on page 260 ? ddrsdrc refresh timer register on page 261 ? ddrsdrc configuration register on page 262 ? ddrsdrc timing 0 parameter register on page 265 ? ddrsdrc timing 1 parameter register on page 267 ? ddrsdrc timing 2 parameter register on page 268 ? ddrsdrc memory device register on page 271 ? ddrsdrc high speed register on page 273
255 6438fCatarmC21-jun-10 at91sam9g45 22.5 software interface/sdram organization, address mapping the sdram address space is organized into banks, rows and columns. the ddrsdrc maps different memory types depending on the values set in the ddrsdrc configuration register. see section 22.7.3 ddrsdrc configuration register on page 262 . the following figures illus- trate the relation between cpu addresses and columns, rows and banks addresses for 16-bit memory data bus widths and 32-bit memory data bus widths. the ddrsdrc supports address mapping in linear mode . linear mode is a method for address mapping where banks alternate at each last sdram page of current bank. . the ddrsdrc makes the sdram devices acce ss protocol transparent to the user. table 22-1 to table 22-8 illustrate the sdram device memory mapping seen by th e user in correlation with the device structure. various configurations are illustrated. 22.5.1 sdram address mapping for 16-bit memory data bus width (1) and four banks table 22-1. linear mapping for sdram configuration, 2k rows, 512/1024/2048/4096 columns cpu address line 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 bk[1:0] row[10:0] column[8:0] m0 bk[1:0] row[10:0] column[9:0] m0 bk[1:0] row[10:0] column[10:0] m0 bk[1:0] row[10:0] column[11:0] m0 table 22-2. linear mapping for sdram configuration: 4k rows, 512/1024/2048/4096 columns cpu address line 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 bk[1:0] row[11:0] column[8:0] m0 bk[1:0] row[11:0] column[9:0] m0 bk[1:0] row[11:0] column[10:0] m0 bk[1:0] row[11:0] column[11:0] m0
256 6438fCatarmC21-jun-10 at91sam9g45 note: 1. sdr-sdram devices with eight columns in 16-bit mode are not supported. 22.5.2 sdr-sdram address mapping for 32-bit memory data bus width table 22-3. linear mapping for sdram configuration: 8k rows, 512/1024/2048/4096 columns cpu address line 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 bk[1:0] row[12:0] column[8:0] m0 bk[1:0] row[12:0] column[9:0] m0 bk[1:0] row[12:0] column[10:0] m0 bk[1:0] row[12:0] column[11:0] m0 table 22-4. linear mapping for sdram configuration: 16k rows, 512/1024/2048 columns cpu address line 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 bk[1:0] row[13:0] column[8:0] m0 bk[1:0] row[13:0] column[9:0] m0 bk[1:0] row[13:0] column[10:0] m0 table 22-6. sdr-sdram configuration mapping: 2k rows, 256/512/1024/2048 columns cpu address line 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 bk[1:0] row[10:0] column[7:0] m[1:0] bk[1:0] row[10:0] column[8:0] m[1:0] bk[1:0] row[10:0] column[9:0] m[1:0] bk[1:0] row[10:0] column[10:0] m[1:0] table 22-7. sdr-sdram configuration mapping: 4k rows, 256/512/1024/2048 columns cpu address line 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 bk[1:0] row[11:0] column[7:0] m[1:0] bk[1:0] row[11:0] column[8:0] m[1:0] bk[1:0] row[11:0] column[9:0] m[1:0] bk[1:0] row[11:0] column[10:0] m[1:0]
257 6438fCatarmC21-jun-10 at91sam9g45 notes: 1. m[1:0] is the byte address inside a 32-bit word. 2. bk[1] = ba1, bk[0] = ba0 table 22-8. sdr-sdram configuration mapping: 8k rows, 256/512/1024/2048 columns cpu address line 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 bk[1:0] row[12:0] column[7:0] m[1:0] bk[1:0] row[12:0] column[8:0] m[1:0] bk[1:0] row[12:0] column[9:0] m[1:0] bk[1:0] row[12:0] column[10:0] m[1:0]
258 6438fCatarmC21-jun-10 at91sam9g45 22.6 programmable io delays the external bus interface consists of a data bus, an address bus and control signals. the simul- taneous switching outputs on these busses may lead to a peak of current in the internal and external power supply lines. in order to reduce the peak of current in such cases, additional propagation delays can be adjusted independently for pad buffers by means of configuration registers, ddrsdrc_delay1-8. the additional programmable delays for each io range from 0 to 4 ns (worst case pvt). the delay can differ between ios supporting this feature. delay can be modified per programming for each io. the minimal additional delay that can be programmed on a pad supporting this feature is 1/16 of the maximum programmable delay. when programming 0x0 in fields delay1 to dela y8, no delay is added (reset value) and the propagation delay of the pad buffers is the inherent delay of the pad buffer. when programming 0xf in field delay1 the propagation del ay of the corresponding pad is maximal. ddrsdrc_delay1, ddrsdrc_delay2 allow to configure delay on d[15:0], ddrsdrc_delay1[3:0] correspo nds to d[0] and ddrsdrc_de lay2[3:0] corresponds to d[8]. ddrsdrc_delay3, ddrsdrc_delay4 allow to configure delay on a13:0], ddrsdrc_delay3[3:0] corresponds to a[0] and ddrsdrc_delay4[3:0] corresponds to a[8]. figure 22-26. programmable io delays 22.7 ddr-sdram controller (d drsdrc) user interface the user interface is connected to the apb bus. delay1 d[0] programmable delay line smc d_out[0] d_in[0] delay2 d[1] programmable delay line d_out[1] d_in[1] delayx d[n] programmable delay line d_out[n] d_in[n] a[m] programmable delay line delayy a[m]
259 6438fCatarmC21-jun-10 at91sam9g45 the ddrsdrc is programmed us ing the registers listed in table 22-9 . table 22-9. register mapping offset register name access reset 0x00 ddrsdrc mode register ddrsdrc_mr read-write 0x00000000 0x04 ddrsdrc refresh timer register ddrsdrc_rtr read-write 0x00000000 0x08 ddrsdrc configuration register ddrsdrc_cr read-write 0x7024 0x0c ddrsdrc timing0 register ddrsdrc_t0pr read-write 0x20227225 0x10 ddrsdrc timing1 register ddrsdrc_t1pr read-write 0x3c80808 0x14 ddrsdrc timing2 register ddrsdrc_t2pr read-write 0x2062 0x18 reserved C C C 0x1c ddrsdrc low-power register ddrsdrc_lpr read-write 0x10000 0x20 ddrsdrc memory device register ddrsdrc_md read-write 0x10 0x24 ddrsdrc dll information register ddrsdrc_dll read-only 0x00000001 0x2c ddrsdrc high speed register ddrsdrc_hs read-write 0x0 0x34 ddrsdrc delay i/o register ddrsdrc_delay1 read-write 0x00000000 0x38 ddrsdrc delay i/o register ddrsdrc_delay2 read-write 0x00000000 0x3c ddrsdrc delay i/o register ddrsdrc_delay3 read-write 0x00000000 0x40 ddrsdrc delay i/o register ddrsdrc_delay4 read-write 0x00000000 0x44 reserved C C C 0x48-0x4c reserved - - - 0x58-0xe0 reserved C C C 0xe4 ddrsdrc write protect mode register ddrsdrc_wpmr read-write 0x00000000 0xe8 ddrsdrc write protect status register ddrsdrc_wpsr read-only 0x00000000
260 6438fCatarmC21-jun-10 at91sam9g45 22.7.1 ddrsdrc mode register name: ddrsdrc_mr access: read-write reset: see table 22-9 this register can only be written if the bit wpen is cleared in ddrsdrc write protect mode register on page 275 . ? mode: ddrsdrc command mode this field defines the command issued by the ddrsdrc when th e sdram device is accessed. th is register is used to ini- tialize the sdram device and to activate deep power-down mode. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCC mode mode description 000 normal mode. any access to the ddrsdrc will be decoded normally. to activate this mode, command must be followed by a write to the sdram. 001 the ddrsdrc issues a nop comman d when the sdram device is accessed rega rdless of the cycle. to activate this mode, command must be followed by a write to the sdram. 010 the ddrsdrc issues an all banks precharge command when the sdram device is accessed regardless of the cycle. to activate this mode, command must be followed by a write to the sdram. 011 the ddrsdrc issues a load mode register command when the sdram device is accessed regardless of the cycle. to activate this mode, command must be followed by a write to the sdram. 100 the ddrsdrc issues an auto-refresh command when the sdram device is accessed regardless of the cycle. previously, an all banks precharge command must be issued. to activate this mode, command must be followed by a write to the sdram. 101 the ddrsdrc issues an extended load mode register command when the sdram device is accessed regardless of the cycle. to activate this mode, the extended load mode regi ster command must be followed by a write to the sdram. the write in the sdram must be done in the appropriate bank. 110 deep power mode: access to deep power-down mode 111 reserved
261 6438fCatarmC21-jun-10 at91sam9g45 22.7.2 ddrsdrc refresh timer register name: ddrsdrc_rtr access: read-write reset: see table 22-9 this register can only be written if the bit wpen is cleared in ddrsdrc write protect mode register on page 275 . ? count: ddrsdrc refresh timer count this 12-bit field is loaded into a timer which generates the refresh pulse. each time the refresh pulse is generated, a refresh sequence is initiated. sdram devices require a refresh of all rows every 64 ms. the value to be lo aded depends on th e ddrsdrc clock fre- quency (mck: master clock) and the number of rows in the device. for example, for an sdram with 8192 rows and a 100 mhz ma ster clock, the value of refresh timer count bit is pro- grammed: (((64 x 10 -3 )/8192) x100 x10 6 = 781 or 0x030d. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCC count 76543210 count
262 6438fCatarmC21-jun-10 at91sam9g45 22.7.3 ddrsdrc configuration register name: ddrsdrc_cr access: read-write reset: see table 22-9 this register can only be written if the bit wpen is cleared in ddrsdrc write protect mode register on page 275 . ? nc: number of column bits the reset value is 9 column bits. sdr-sdram devices with eight columns in 16-bit mode (b16mode ==1) are not supported. ? nr: number of row bits the reset value is 12 row bits. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCactbstCdqms 15 14 13 12 11 10 9 8 C ocd C C dis_dll dic/ds 76543210 dll cas nr nc nc ddr - column bits sdr - column bits 00 98 01 10 9 10 11 10 11 12 11 nr row bits 00 11 01 12 10 13 11 14
263 6438fCatarmC21-jun-10 at91sam9g45 ? cas: cas latency the reset value is 2 cycles. ? dll: reset dll reset value is 0. this field defines the value of reset dll. 0 = disable dll reset. 1 = enable dll reset. this value is used during the power-up sequence. note: this field is found only in ddr1-sdram devices . ? dic/ds: output driver impedance control: reset value is 0. this field defines the output drive strength. 0 = normal driver strength. 1 = weak driver strength. this value is used during the power-up sequence. this parameter is found in the datasheet as dic or ds. note: this field is found only in ddr2-sdram devices . ? dis_dll: disable dll 0 = enable dll 1 = disable dll ? ocd: off-chip driver reset value is 3b111. note: ocd is not supported by the controller, but these values must be programmed during the initialization sequence. cas ddr2 cas latency sdr cas latency 000 reserved reserved 001 reserved reserved 010 reserved 2 011 33 100 reserved reserved 101 reserved reserved 110 reserved reserved 111 reserved reserved ocd 000 ocd calibration mode exit, maintain setting 111 ocd calibration default
264 6438fCatarmC21-jun-10 at91sam9g45 ? dqms: mask data is shared reset value is 0. 0 = dqm is not shared with another controller. 1 = dqm is shared with another controller. ? actbst: active bank x to burst stop read access bank y reset value is 0. 0 = after an active command in bank x, burst stop command can be issued to another bank to stop current read access. 1 = after an active command in bank x, burst stop command cannot be issued to another bank to stop current read access. this field is unique to sdr-sdram, low-powe r sdr-sdram and low-power ddr-sdram devices.
265 6438fCatarmC21-jun-10 at91sam9g45 22.7.4 ddrsdrc timing 0 parameter register name: ddrsdrc_t0pr access: read-write reset: see table 22-9 this register can only be written if the bit wpen is cleared in ddrsdrc write protect mode register on page 275 . ? tras: active to precharge delay reset value is 5 cycles. this field defines the delay between an activate command and a precharge command in number of cycles. number of cycles is between 0 and 15. ? trcd: row to column delay reset value is 2 cycles. this field defines the delay between an activate comman d and a read/write command in number of cycles. number of cycles is between 0 and 15. ? twr: write recovery delay reset value is 2. this field defines the write recovery time in numb er of cycles. number of cycles is between 1 and 15. ? trc: row cycle delay reset value is 7 cycles. this field defines the delay between an activate command and refresh command in number of cycles. number of cycles is between 0 and 15 ? trp: row precharge delay reset value is 2 cycles. this field defines the delay between a precharge command and another command in number of cycles. number of cycles is between 0 and 15. ? trrd active banka to active bankb reset value is 2. this field defines the delay between an active command in banka and an active command in bankb in number of cycles. number of cycles is between 1 and 15. 31 30 29 28 27 26 25 24 tmrd reduce_wrrd twtr 23 22 21 20 19 18 17 16 trrd trp 15 14 13 12 11 10 9 8 trc twr 76543210 trcd tras
266 6438fCatarmC21-jun-10 at91sam9g45 ? twtr: internal write to read delay reset value is 0. this field defines the internal write to read command time in number of cycles. number of cycles is between 1 and 7. in the case of low-power ddr-sdram device only bit 24 (twtr[0]) is used. bit [26:25] must be set to 0. ? reduce_wrrd: reduce write to read delay reset value is 0. this field reduces the delay between write to read access for low-power ddr-sdram devices with a latency equal to 2. to use this feature, twtr field must be equal to 0. important to note is that some devices do not support this feature. ? tmrd: load mode register command to active or refresh command reset value is 2 cycles. this field defines the delay between a load mode register command and an active or refresh command in number of cycles. number of cycles is between 0 and 15. bit 24 (twtr[0]) twtr value 0 1 1 2
267 6438fCatarmC21-jun-10 at91sam9g45 22.7.5 ddrsdrc timing 1 parameter register name: ddrsdrc_t1pr access: read-write reset: see table 22-9 this register can only be written if the bit wpen is cleared in ddrsdrc write protect mode register on page 275 . ? trfc: row cycle delay reset value is 8 cycles. this field defines the delay between a refresh and an activate command or refresh command in number of cycles. num- ber of cycles is between 0 and 31 ? txsnr: exit self refresh delay to non-read command reset value is 8 cycles. this field defines the delay between cke set high and a non read command in number of cycles. number of cycles is between 0 and 15. this field is used for sdr-sdram and ddr-sdram devices. in the case of sdr-sdram devices and low-power ddr-sdram, this field is equivalent to txsr timing. ? txsrd: exit self refresh delay to read command reset value is c8. this field defines the delay between cke set high and a read command in number of cycles . number of cycles is between 0 and 255 cycles.this field is unique to ddr-sdram devices. ? txp: exit power-down delay to first command reset value is 3. this field defines the delay between cke set high and a valid command in number of cycles. number of cycles is between 0 and 15 cycles. this field is unique to low-po wer ddr-sdram devices and ddr2-sdram devices. 31 30 29 28 27 26 25 24 CCCC txp 23 22 21 20 19 18 17 16 txsrd 15 14 13 12 11 10 9 8 txsnr 76543210 CCC trfc
268 6438fCatarmC21-jun-10 at91sam9g45 22.7.6 ddrsdrc timing 2 parameter register name: ddrsdrc_t2pr access: read-write reset: see table 22-9 this register can only be written if the bit wpen is cleared in ddrsdrc write protect mode register on page 275 . ? txard: exit active power down delay to read command in mode ?fast exit?. the reset value is 0 cycle. this field defines the delay between cke set high and a read command in number of cycles . number of cycles is between 0 and 15. note: this field is found only in ddr2-sdram devices . ? txards: exit active power down delay to read command in mode ?slow exit?. the reset value is 0 cycle. this field defines the delay between cke set high and a read command in number of cycles . number of cycles is between 0 and 15. note: this field is found only in ddr2-sdram devices . ? trpa: row precharge all delay the reset value is 0 cycle. this field defines the dela y between a precharge all ba nks command and another comma nd in number of cycles. num- ber of cycles is between 0 and 15. note: this field is found only in ddr2-sdram devices . ? trtp: read to precharge the reset value is 2 cycles. this field defines the delay between read command and a precharge command in number of cycle. number of cycles is between 0 and 15. 31 30 29 28 27 26 25 24 CC CCCCCC 23 22 21 20 19 18 17 16 CC CCCCCC 15 14 13 12 11 10 9 8 trtp trpa 76543210 txards txard
269 6438fCatarmC21-jun-10 at91sam9g45 22.7.7 ddrsdrc low-power register name: ddrsdrc_lpr access: read-write reset: see table 22-9 ? lpcb: low-power command bit reset value is 00. 00 = low-power feature is inhibited: no power-down, self refresh and deep power mode are issued to the sdram device. 01 = the ddrsdrc issues a self refresh command to the s dram device, the clock(s) is/a re de-activated and the cke signal is set low. the sdram device leaves the self re fresh mode when accessed and enters it after the access. 10 = the ddrsdrc issues a power-down command to the sdra m device after each access, the cke signal is set low. the sdram device leaves the power-down mode when accessed and enters it after the access. 11 = the ddrsdrc issues a deep power-down command to the low-power sdram device. this mode is unique to low-power sdram devices. ? clk_fr: clock frozen command bit reset value is 0. this field sets the clock low during power-down mode or during deep power-down mode. some sdram devices do not support freezing the clock during power-down mode or du ring deep power-down mode. refer to the sdram device datasheet for details on this. 1 = clock(s) is/are frozen. 0 = clock(s) is/are not frozen. ? pasr: partial array self refresh reset value is 0. this field is unique to low-power sdram. it is used to specify whether only one quarter, one half or all banks of the sdram array are enabled. disabled banks are not refreshed in self refresh mode. the values of this field are dependant on low-power sdram devices. after the initialization se quence, as soon as pasr field is modified, extended mo de register in the external device mem- ory is accessed automatically and pasr bits are updated. in function of the upd_mr bit, update is done before entering in self refresh mode or during a refresh command and a pending read or write access. 31 30 29 28 27 26 25 24 CC CCCCCC 23 22 21 20 19 18 17 16 C C upd_mr C C C apde 15 14 13 12 11 10 9 8 CC timeout ds tcr 76543210 C pasr clk_fr lpcb
270 6438fCatarmC21-jun-10 at91sam9g45 ? tcr: temperature compensated self refresh reset value is 0. this field is unique to low-power sdram . it is used to program the refresh interval during self refresh mode, depending on the case temperature of the low-power sdram. the values of this field are dependent on low-power sdram devices. after the initialization sequence, as soon as tcr field is modified, extended mode register is accessed automatically and tcr bits are updated. in function of upd_mr bit, update is done before entering in self refresh mode or during a refresh command and a pending read or write access. ? ds: drive strength reset value is 0. this field is unique to low-power sdram . it selects the driver strength of sdram output. after the initialization sequence, as soon as ds field is mo dified, extended mode register is accessed automatically and ds bits are updated. in function of upd_mr bit, update is done before entering in self refresh mode or during a refresh command and a pending read or write access. ?timeout reset value is 00. this field defines when low-power mode is enabled. ? apde: active power down exit time reset value is 1. this mode is unique to ddr2-sdram devices. this mode allows to determine the active power-down mode, which determines performance versus power saving . 0 = fast exit 1 = slow exit after the initialization sequence, as soon as apde field is modified extended mode register, located in the memory of the external device, is accessed automatically and apde bits are updated. in function of the upd_mr bit, update is done before entering in self refresh mode or during a refresh command and a pending read or write access ? upd_mr: update load mode register and extended mode register reset value is 0. this bit is used to enable or disabl e automatic update of the load mode register and extended mode register. this update is function of ddrsdrc integration in a system. d drsdrc can either share or not share an external bus with another controller. 00 the sdram controller activates the sdram low-power mo de immediately after the end of the last transfer. 01 the sdram controller activates the sdram low-power mo de 64 clock cycles after the end of the last transfer. 10 the sdram controller activates the sdram low-power mo de 128 clock cycles after the end of the last transfer. 11 reserved 00 update is disabled. 01 ddrsdrc shares external bus. automatic update is done during an refresh command and a pending read or write access in sdram dev ice. 10 ddrsdrc does not share external bus. automatic updat e is done before entering in self refresh mode. 11 reserved
271 6438fCatarmC21-jun-10 at91sam9g45 22.7.8 ddrsdrc memory device register name: ddrsdrc_md access: read-write reset: see table 22-9 this register can only be written if the bit wpen is cleared in ddrsdrc write protect mode register on page 275 . ? md: memory device indicates the type of memory used. reset value is for sdr-sdram device. 000 = sdr-sdram 001 = low-power sdr-sdram 010 = reserved 011 = low-power ddr1-sdram 110 = ddr2-sdram ? dbw: data bus width reset value is 16 bits. 0 = data bus width is 32 bits (reserved for sdr-sdram device). 1 = data bus width is 16 bits. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCdbwC md
272 6438fCatarmC21-jun-10 at91sam9g45 22.7.9 ddrsdrc dll register name: ddrsdrc_dll access: read-only reset: see table 22-9 the dll logic is internally used by the controller in order to delay dqs inputs. this is necessary to center the strobe time and the data valid window. ? mdinc: dll master delay increment 0 = the dll is not incrementing the master delay counter. 1 = the dll is incrementing the master delay counter. ? mddec: dll master delay decrement 0 = the dll is not decrementing the master delay counter. 1 = the dll is decrementing the master delay counter. ?mdovf : dll master delay overflow flag 0 = the master delay counter has not reached its maximum value, or the master is not locked yet. 1 = the master delay counter has reached its maximum value, the master delay counter increment is stopped and the dll forces the master lock. if this flag is set, it means the d drsdrc clock frequency is too low compared to master delay line number of elements. ?mdval : dll master delay value value of the master delay counter. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 mdval 76543210 CCCCCmdovfmddecmdinc
273 6438fCatarmC21-jun-10 at91sam9g45 22.7.10 ddrsdrc hi gh speed register name: ddrsdrc_hs access: read-write reset: see table 22-9 this register can only be written if the bit wpen is cleared in ddrsdrc write protect mode register on page 275 . ? dis_anticip_read 0 = anticip read access is enabled. 1 = anticip read access is disabled (default). dis_anticip_read allows ddr2 read access optimization with multi-port. as this f eature is based on the "bank open policy", the software must map differ ent buffers in different ddr2 banks to take advan tage of that feature. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCC dis_anticip_re ad CC
274 6438fCatarmC21-jun-10 at91sam9g45 22.7.11 ddrsdrc delay i/o register name: ddrsdrc_delayx [x=1..4] access: read-write reset: see table 22-9 ?delayx: gives the number of elements in the delay line. 31 30 29 28 27 26 25 24 delay8 delay7 23 22 21 20 19 18 17 16 delay6 delay5 15 14 13 12 11 10 9 8 delay4 delay3 76543210 delay2 delay1
275 6438fCatarmC21-jun-10 at91sam9g45 22.7.12 ddrsdrc write protect mode register name: ddrsdrc_wpmr access: read-write reset: see table 22-9 ? wpen: write protect enable 0 = disables the write protect if wpkey corresponds to 0x4444 52 (ddr in ascii). 1 = enables the write protect if wpkey corresponds to 0x444452 (ddr in ascii). protects the registers: ? ddrsdrc mode register on page 260 ? ddrsdrc refresh timer register on page 261 ? ddrsdrc configuration register on page 262 ? ddrsdrc timing 0 parameter register on page 265 ? ddrsdrc timing 1 parameter register on page 267 ? ddrsdrc timing 2 parameter register on page 268 ? ddrsdrc memory device register on page 271 ? ddrsdrc high speed register on page 273 ? wpkey: write protect key should be written at value 0x444452 (ddr in ascii). writing any other value in this field aborts the write operation of the wpen bit. always reads as 0. 31 30 29 28 27 26 25 24 wpkey 23 22 21 20 19 18 17 16 wpkey 15 14 13 12 11 10 9 8 wpkey 76543210 wpen
276 6438fCatarmC21-jun-10 at91sam9g45 22.7.13 ddrsdrc write protect status register name: ddrsdrc_wpsr access: read-only reset: see table 22-9 ? wpvs: write protect violation status 0 = no write protect violation has occurred since the last read of the ddrsdrc_wpsr register. 1 = a write protect violation has occurred since the last read of the ddrsdrc_wpsr register. if this violation is an unau- thorized attempt to write a protected register, the associated violation is reported into field wpvsrc. ? wpvsrc: write protect violation source when wpvs is active, this field indicates the write-protected register (t hrough address offset or code) in which a write access has been attempted. note: reading ddrsdrc_wpsr automatically clears all fields. 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 wpvsrc 15 14 13 12 11 10 9 8 wpvsrc 76543210 wpvs
277 6438fCatarmC21-jun-10 at91sam9g45 23. peripheral dma controller (pdc) 23.1 description the peripheral dma controller (pdc) transfers data between on-chip serial peripherals and the on- and/or off-chip memories. the link betw een the pdc and a serial peripheral is operated by the ahb to abp bridge. the user interface of each pdc channel is integrat ed into the user interface of the peripheral it serves. the user interface of mono directional channels (receive only or transmit only), contains two 32-bit memory pointers and two 16-bit counters, one set (pointer, counter) for current trans- fer and one set (pointer, counter) for next transfer. the bi-directional channel user interface contains four 32-bit memory pointers and four 16-bit counters. each set (pointer, counter) is used by current transmit, next transmi t, current receive and next receive. using the pdc removes processor overhead by reducing its intervention during the transfer. this significantly reduces the number of clock cycles required for a data transfer, which improves microcontroller performance. to launch a transfer, the peripheral triggers its associated pdc channels by using transmit and receive signals. when the programmed data is transferred, an end of transfer interrupt is gener- ated by the peripheral itself. 23.2 embedded characteristics ? acting as one ahb bus matrix master ? allows data transfers from/to peripheral to/from any memory space without any intervention of the processor. ? next pointer support, prevents strong real-time constraints on buffer management. the peripheral dma controller handles transfer requests from the channel according to the fol- lowing priorities (low to high priorities): table 23-1. peripheral dma controller instance name channel t/r dbgu transmit usart3 transmit usart2 transmit usart1 transmit usart0 transmit ac97c transmit spi1 transmit spi0 transmit ssc1 transmit ssc0 transmit tsadcc receive dbgu receive usart3 receive
278 6438fCatarmC21-jun-10 at91sam9g45 usart2 receive usart1 receive usart0 receive ac97c receive spi1 receive spi0 receive ssc1 receive ssc0 receive table 23-1. peripheral dma controller instance name channel t/r
279 6438fCatarmC21-jun-10 at91sam9g45 23.3 block diagram figure 23-1. block diagram 23.4 functional description 23.4.1 configuration the pdc channel user interface enables the user to configure and control data transfers for each channel. the user interface of each pdc channel is integrated into the associated periph- eral user interface. the user interface of a serial peripheral, whether it is full or half duplex, contains four 32-bit pointers (rpr, rnpr, tpr, tn pr) and four 16-bit counter registers (rcr, rncr, tcr, tncr). however, the transmit and receive parts of each type are programmed differently: the pdc full duplex peripheral thr rhr pdc channel a pdc channel b control status & control control pdc channel c half duplex peripheral thr status & control receive or transmit peripheral rhr or thr control control rhr pdc channel d status & control
280 6438fCatarmC21-jun-10 at91sam9g45 transmit and receive parts of a full duplex peripheral can be programmed at the same time, whereas only one part (transmit or receive) of a half duplex peripheral can be programmed at a time. 32-bit pointers define the access location in memory for current and next transfer, whether it is for read (transmit) or write (receive). 16-bit counters define the size of current and next transfers. it is possible, at any moment, to read the number of transfers left for each channel. the pdc has dedicated status registers which indica te if the transfer is enabled or disabled for each channel. the status for each channel is located in the associated peripheral status register. transfers can be enabled and/or disabled by setting txten/txtdis and rxten/rxtdis in the peripherals transfer control register. at the end of a transfer, the pdc channel sends status flags to its associated peripheral. these flags are visible in the peripheral status register (endrx, endtx, rxbuff, and txbufe). refer to section 23.4.3 and to the associated peripheral user interface. 23.4.2 memory pointers each full duplex peripheral is connected to the pdc by a receive channel and a transmit chan- nel. both channels have 32-bit memory pointers that point respectively to a receive area and to a transmit area in on- and/or off-chip memory. each half duplex peripheral is connected to the pdc by a bidirectional channel. this channel has two 32-bit memory pointers, one for current transfer and the other for next transfer. these pointers point to transmit or receive data depending on the operating mode of the peripheral. depending on the type of transfer (byte, half-word or word), the memory pointer is incremented respectively by 1, 2 or 4 bytes. if a memory pointer address changes in the middle of a transfer, the pdc channel continues operating using the new address. 23.4.3 transfer counters each channel has two 16-bit counters, one for current transfer and the other one for next trans- fer. these counters define the size of data to be transferred by the channel. the current transfer counter is decremented first as the data addresse d by current memory pointer starts to be trans- ferred. when the cu rrent transfer counter re aches zero, the channel checks its next transfer counter. if the value of next counter is zero, the channel stops transferring data and sets the appropriate flag. but if the next counter value is greater then zero, the values of the next pointer/next counter are copied into the current pointer/current counter and the channel resumes the transfer whereas next pointer/next counter get zero/zero as values. at the end of this trans- fer the pdc channel sets the appropriate flags in the peripheral status register. the following list gives an overview of how status register flags behave depending on the coun- ters values: ? endrx flag is set when the periph_rcr register reaches zero. ? rxbuff flag is set when both per iph_rcr and periph_rncr reach zero. ? endtx flag is set when the periph_tcr register reaches zero. ? txbufe flag is set when both periph_tcr and periph_tncr reach zero. these status flags are described in the peripheral status register.
281 6438fCatarmC21-jun-10 at91sam9g45 23.4.4 data transfers the serial peripheral triggers its associated pdc channels transfers using transmit enable (txen) and receive enable (rxen) flags in the transfer control register integrated in the periph- erals user interface. when the peripheral receives an external data, it sends a receive ready signal to its pdc receive channel which then requests access to the matrix. when access is granted, the pdc receive channel starts reading the peripheral receive holding register (rhr). the read data are stored in an internal buffer and then written to memory. when the peripheral is about to send data, it sends a transmit ready to its pdc transmit chan- nel which then requests access to the matrix. when access is granted, the pdc transmit channel reads data from memory and puts them to transmit holding regist er (thr) of its asso- ciated peripheral. the same peripheral sends data according to its mechanism. 23.4.5 pdc flags and peripheral status register each peripheral connected to the pdc sends out receive ready and transmit ready flags and the pdc sends back flags to the peripheral. all these flags are only visible in the peripheral status register. depending on the type of peripheral, half or full duplex, the flags belong to either one single channel or two different channels. 23.4.5.1 receive transfer end this flag is set when periph_rcr register reaches zero and the last data has been transferred to memory. it is reset by writing a non zero value in periph_rcr or periph_rncr. 23.4.5.2 transmit transfer end this flag is set when periph_tcr register reaches zero and the last data has been written into peripheral thr. it is reset by writing a non zero value in periph_tcr or periph_tncr. 23.4.5.3 receive buffer full this flag is set when periph_rcr register reac hes zero with periph_rncr also set to zero and the last data has been transferred to memory. it is reset by writing a non zero value in periph_tcr or periph_tncr. 23.4.5.4 transmit buffer empty this flag is set when periph_tcr register reac hes zero with periph_tncr also set to zero and the last data has been written into peripheral thr. it is reset by writing a non zero value in periph_tcr or periph_tncr.
282 6438fCatarmC21-jun-10 at91sam9g45 23.5 peripheral dma controll er (pdc) user interface note: 1. periph: ten registers are mapped in the peripheral memory space at the same offset. these can be defined by the user according to the function and the desired peripheral.) table 23-2. register mapping offset register name access reset 0x100 receive pointer register periph (1) _rpr read-write 0 0x104 receive counter register periph_rcr read-write 0 0x108 transmit pointer register periph_tpr read-write 0 0x10c transmit counter register periph_tcr read-write 0 0x110 receive next pointer register periph_rnpr read-write 0 0x114 receive next counter register periph_rncr read-write 0 0x118 transmit next pointer register periph_tnpr read-write 0 0x11c transmit next counter register periph_tncr read-write 0 0x120 transfer control register periph_ptcr write-only 0 0x124 transfer status register periph_ptsr read-only 0
283 6438fCatarmC21-jun-10 at91sam9g45 23.5.1 receive pointer register name: periph_rpr access: read-write ? rxptr: receive pointer register rxptr must be set to receive buffer address. when a half duplex peripheral is connected to the pdc, rxptr = txptr. 31 30 29 28 27 26 25 24 rxptr 23 22 21 20 19 18 17 16 rxptr 15 14 13 12 11 10 9 8 rxptr 76543210 rxptr
284 6438fCatarmC21-jun-10 at91sam9g45 23.5.2 receive counter register name: periph_rcr access: read-write ? rxctr: receive counter register rxctr must be set to receive buffer size. when a half duplex peripheral is connected to the pdc, rxctr = txctr. 0 = stops peripheral data transfer to the receiver 1 - 65535 = starts peripheral data transfer if corresponding channel is active 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 rxctr 76543210 rxctr
285 6438fCatarmC21-jun-10 at91sam9g45 23.5.3 transmit pointer register name: periph_tpr access: read-write ? txptr: transmit counter register txptr must be set to transmit buffer address. when a half duplex peripheral is connected to the pdc, rxptr = txptr. 31 30 29 28 27 26 25 24 txptr 23 22 21 20 19 18 17 16 txptr 15 14 13 12 11 10 9 8 txptr 76543210 txptr
286 6438fCatarmC21-jun-10 at91sam9g45 23.5.4 transmit counter register name: periph_tcr access: read-write ? txctr: transmit counter register txctr must be set to transmit buffer size. when a half duplex peripheral is connected to the pdc, rxctr = txctr. 0 = stops peripheral data transfer to the transmitter 1- 65535 = starts peripheral data transfer if corresponding channel is active 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 txctr 76543210 txctr
287 6438fCatarmC21-jun-10 at91sam9g45 23.5.5 receive next pointer register name: periph_rnpr access: read-write ? rxnptr: receive next pointer rxnptr contains next receive buffer address. when a half duplex peripheral is connected to the pdc, rxnptr = txnptr. 31 30 29 28 27 26 25 24 rxnptr 23 22 21 20 19 18 17 16 rxnptr 15 14 13 12 11 10 9 8 rxnptr 76543210 rxnptr
288 6438fCatarmC21-jun-10 at91sam9g45 23.5.6 receive next counter register name: periph_rncr access: read-write ? rxnctr: receive next counter rxnctr contains next receive buffer size. when a half duplex peripheral is connected to the pdc, rxnctr = txnctr. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 rxnctr 76543210 rxnctr
289 6438fCatarmC21-jun-10 at91sam9g45 23.5.7 transmit next pointer register name: periph_tnpr access: read-write ? txnptr: transmit next pointer txnptr contains next transmit buffer address. when a half duplex peripheral is connected to the pdc, rxnptr = txnptr. 31 30 29 28 27 26 25 24 txnptr 23 22 21 20 19 18 17 16 txnptr 15 14 13 12 11 10 9 8 txnptr 76543210 txnptr
290 6438fCatarmC21-jun-10 at91sam9g45 23.5.8 transmit next counter register name: periph_tncr access: read-write ? txnctr: transmit counter next txnctr contains next transmit buffer size. when a half duplex peripheral is connected to the pdc, rxnctr = txnctr. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 txnctr 76543210 txnctr
291 6438fCatarmC21-jun-10 at91sam9g45 23.5.9 transfer control register name: periph_ptcr access: write-only ? rxten: receiver transfer enable 0 = no effect. 1 = enables pdc receiver channel requests if rxtdis is not set. when a half duplex peripheral is connected to the pdc, en abling the receiver channel requests automatically disables the transmitter channel requests. it is forbidden to set both txten and rxten for a half duplex peripheral. ? rxtdis: receiver transfer disable 0 = no effect. 1 = disables the pdc receiver channel requests. when a half duplex peripheral is connecte d to the pdc, disabling the receiver chann el requests also disables the transmit- ter channel requests. ? txten: transmitter transfer enable 0 = no effect. 1 = enables the pdc transmitter channel requests. when a half duplex peripheral is connected to the pdc, it en ables the transmitter channel requests only if rxten is not set. it is forbidden to set both txten and rxten for a half duplex peripheral. ? txtdis: transmitter transfer disable 0 = no effect. 1 = disables the pdc transmitter channel requests. when a half duplex peripheral is connected to the pdc, dis abling the transmitter channel requests disables the receiver channel requests. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCtxtdistxten 76543210 CCCCCCrxtdisrxten
292 6438fCatarmC21-jun-10 at91sam9g45 23.5.10 transfer status register name: periph_ptsr access: read-only ? rxten: receiver transfer enable 0 = pdc receiver channel requests are disabled. 1 = pdc receiver channel requests are enabled. ? txten: transmitter transfer enable 0 = pdc transmitter channel requests are disabled. 1 = pdc transmitter channel requests are enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCtxten 76543210 CCCCCCCrxten
293 6438fCatarmC21-jun-10 at91sam9g45 24. clock generator 24.1 description the clock generator user interface is embedded within the power management controller interface and is described in section 25.11 . however, the clock generator registers are named ckgr_. 24.2 embedded characteristics the clock generator is made up of: ? one low power 32768 hz slow clock oscillator with bypass mode ? one low-power rc oscillator ? one 12 mhz main oscillato r, which can be bypassed ? one 400 to 800 mhz programmable plla, capable to provide the clock mck to the processor and to the peripherals. this pll has an input divider to offer a wider range of output frequencies from the 12 mhz input, the only limitation being the lowest input frequency shall be higher or equal to 2 mhz. the usb device and host hs clocks are provided by a the dedicated utmi pll (upll) embedded in the utmi macro. figure 24-1. clock generator block diagram 24.3 slow clock crystal oscillator the clock generator int egrates a 32,768 hz low-power osc illator. the xin32 and xout32 pins must be connected to a 32,768 hz crystal. two external capacitors must be wired as shown in figure 24-2 . power management controller xin xout main clock mainck control status plla and divider plla clock pllack 12m main oscillator upll on chip rc osc slow clock slck xin32 xout32 slow clock oscillator clock generator rcen upllck oscsel osc32en osc32byp
294 6438fCatarmC21-jun-10 at91sam9g45 figure 24-2. typical slow clock crystal oscillator connection 24.4 slow clock rc oscillator the user has to take into accoun t the possible drifts of the rc oscillator. more details are given in the section dc characteristics of the product datasheet. 24.5 slow clock selection the at91sam9g45 slow clock can be generated either by an external 32,768 hz crystal or by the on-chip rc oscillator. the 32,768 hz crystal oscillator can be bypassed by setting the bit osc32byp to accept an external slow clock on xin32. the internal rc oscillator and th e 32,768 hz oscillator can be en abled by setting to 1, respec- tively, rcen bit and osc32en bit in the syst em controller user interface. the oscsel command selects the slow clock source. figure 24-3. slow clock selection rcen, osc32en,oscsel and osc32byp bits are located in the slow clock control register (sckcr) located at address 0xfffffd50 in the ba cked up part of the system controller and so are preserved while vddbu is present. after a vddbu power on reset, the default configuration is rcen=1, osc32en=0 and osc- sel=0, allowing the system to star t on the internal rc oscillator. the programmer controls the slow clock switching by software and so must take precautions during the switching phase. xin32 xout32 gndpll 32,768 hz crystal on chip rc osc slow clock slck xin32 xout32 slow clock oscillator clock generator osc32en rcen oscsel osc32byp
295 6438fCatarmC21-jun-10 at91sam9g45 24.5.1 switch from internal rc oscillator to the 32768 hz crystal to switch from internal rc osc illator to the 32768 hz crystal, the programm er must execute the following sequence: ? switch the master clock to a source different from slow clock (plla or pllb or main oscillator) through the po wer management controller. ? enable the 32768 hz oscillator by setting the bit oscen to 1. ?wait 32768 hz startup time for clock stabilization (software loop) ? switch from internal rc to 32768hz by setting the bit oscsel to 1. ? wait 5 slow clock cycles for internal resynchronization ? disable the rc oscillator by setting the bit rcen to 0. 24.5.2 bypass the 32768 hz oscillator the following step must be added to bypass the 32768hz oscillator. ? an external clock must be connected on xin32. ? enable the bypass path osc32byp bit set to 1. ? disable the 32768 hz oscillator by setting the bit osc32en to 0. 24.5.3 switch from 32768 hz crystal to the internal rc oscillator the same procedure must be followed to switch from 32768hz crystal to the internal rc oscillator. ? switch the master clock to a source different from slow clock (plla or pllb or main oscillator) ? enable the internal rc oscillator by setting the bit rcen to 1. ?wait internal rc startup time for clock stabilization (software loop) ? switch from 32768hz oscillator to internal rc by setting the bit oscsel to 0 ? wait 5 slow clock cycles for internal resynchronization ? disable the 32768hz oscillator by setting the bit osc32en to 0 24.5.4 slow clock configuration register register name: sckcr address: 0xfffffd50 access type: read/write 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCoscselosc32byposc32enrcen
296 6438fCatarmC21-jun-10 at91sam9g45 ? rcen: internal rc 0: rc is disabled 1: rc is enabled ? osc32en: 32768 hz oscillator 0: 32768hz oscillator is disabled 1: 32768hz oscillator is enabled ? osc32byp: 32768hz oscillator bypass 0: 32768hz oscillator is not bypassed 1: 32768hz oscillator is bypassed, acce pt an external slow clock on xin32 ? oscsel: slow clock selector 0: slow clock is internal rc 1: slow clock is 32768 hz oscillator
297 6438fCatarmC21-jun-10 at91sam9g45 24.6 main oscillator the main oscillator is des igned for a 12 mhz fund amental crystal. the 12 mh z is an input of the plla and the upll used to generate the 480 mhz usb high speed clock (upllck). figure 24-4 shows the main oscillator block diagram. figure 24-4. main oscillator block diagram 24.6.1 main oscillator connections the typical crystal connec tion is illustrated in figure 24-5 . for further details on the electrical characteristics of the main oscillator, see t he section dc characteristics of the product datasheet. figure 24-5. typical crystal connection 24.6.2 main oscillator startup time the startup time of the 12 mhz ma in oscillator is given in the sect ion dc characteristics of the product datasheet. 24.6.3 main oscillator control to minimize the power required to start up the sy stem, the main oscillator is disabled after reset and slow clock is selected. the software enable s or disables the main oscillator so as to reduce po wer consumption by clearing the moscen bit in the ma in oscillator regi ster (ckgr_mor). when disabling the main oscillator by clearin g the moscen bit in ckgr_mor, the moscs bit in pmc_sr is automatica lly cleared, indicating the main clock is off. when enabling the main oscillator, the user must initiate the ma in oscillator coun ter with a value corresponding to the startup time of the oscillat or. this startup time depends on the crystal fre- quency connected to the main oscillator. xin xout main clock mainck plla and divider plla clock pllack 12m main oscillator upll upllck xin xout gnd
298 6438fCatarmC21-jun-10 at91sam9g45 when the moscen bit and the oscount are written in ckgr_mor to enable the main oscil- lator, the moscs bit in pmc_sr (status register) is cleared and the counter starts counting down on the slow clock divided by 8 from the oscount value. since the oscount value is coded with 8 bits, the maximum startup time is about 62 ms. when the counter reaches 0, the moscs bit is set, indicating that the main clock is valid. set- ting the moscs bit in pmc_imr can trigger an interrupt to the processor. 24.6.4 main oscillator bypass the user can input a clock on the device instead of connecting a crystal. in this case, the user has to provide the external clock signal on the xi n pin. the input characteristics of the xin pin under these conditions are given in the product el ectrical characteristics section. the program- mer has to be sure to set the oscbypass bit to 1 and the moscen bit to 0 in the main osc register (ckgr_mor) for the external clock to operate properly. 24.7 divider and plla block the plla embeds an input divider to increase the accuracy of the resulting clock signals. how- ever, the user must respect th e plla minimum input frequency when programming the divider. the plla embeds also an output divisor by 2. figure 24-6 shows the block diagram of the divider and plla block. figure 24-6. divider and plla block diagram 24.7.1 divider and phase lock loop programming the divider can be set between 1 and 255 in steps of 1. when a divider field (div) is set to 0, the output of the corresponding divider and the pll out put is a continuous signal at level 0. on reset, each div field is set to 0, thus the corresponding pll input clock is set to 0. the plla allows multiplication of the divider s outputs. the plla clock signal has a frequency that depends on the respective source signal frequency and on the parameters diva and mula. the factor applied to the source signal frequency is (mula + 1)/diva. when mula is written to 0, the plla is disabled and its power consumption is saved. re-enabling the plla can be performed by writing a value higher than 0 in the mul field. whenever the plla is re-enabled or one of its parameters is changed, the locka bit in pmc_sr is automatically cleared. the values written in the pllacount field in ckgr_pllar are loaded in the plla counter. the plla counter then decrements at the speed of the slow divider diva plla mula pllacount locka outa slck mainck pllack plla counter /1 or /2 divider plladiv2
299 6438fCatarmC21-jun-10 at91sam9g45 clock until it reaches 0. at this time, the lock bit is set in pmc_sr and can trigger an interrupt to the processor. the user has to load the number of slow clock cycles required to cover the plla transient time into the pllacount field. the plla clock can be divided by 2 by writ ing the plladiv2 bit in pmc_mckr register. 24.8 utmi bias and phase lock loop programming the multiplier is built-in to 40 to obtain the usb high speed 480 mhz. whenever the upll is enabled by writing upll en in ckgr_uckr, the locku bit in pmc_sr is automatically cleared. the values written in the pllcount field in ckgr_uckr are loaded in the upll counter. the upll counter then decrements at the speed of the slow clock divided by 8 until it reaches 0. at this time, the locku bit is set in pmc_sr and can trigger an interrupt to the processor. the user has to load the number of slow clock cycles required to cover the upll transient time into the pllcount field. the bias, needed for high speed operations, is enabled by writing biasen in ck gr_uckr once the pll locked. upll pllcount locku upllen slck mainck upllck upll counter
300 6438fCatarmC21-jun-10 at91sam9g45 25. power management controller (pmc) 25.1 description the power management controller (pmc) optimizes power consumption by controlling all sys- tem and user peripheral clocks. the pmc enables/disables the clock inputs to many of the peripherals and the arm processor. 25.2 embedded characteristics the power management controller provides all the clock signals to the system. pmc input clocks: ? upllck: from utmi pll ? pllack from plla ? slck: slow clock from osc32k or internal rc osc ? mainck: from 12 mhz external oscillator pmc output clocks ? processor clock pck ? master clock mck, in particular to the matrix and the memory interfaces. the divider can be 1,2,3 or 4 ? ddr system clock equal to 2xmck note: ddr system clock is not available when ma ster clock (mck) equals processor clock (pck). ? usb host ehci high speed clock (upllck) ? usb ohci clocks (uhp48m and uhp12m) ? independent peripheral clocks, typically at the frequency of mck ? two programmable clock outputs: pck0 and pck1 this allows the software control of five flexible operating modes: ? normal mode, processor and peripherals running at a programmable frequency ? idle mode, processor stopped waiting for an interrupt ? slow clock mode, processor and peripherals running at low frequency ? standby mode, mix of idle and backup mode, peripheral running at low frequency, processor stopped waiting for an interrupt ? backup mode, main power supplies off, vddbu powered by a battery
301 6438fCatarmC21-jun-10 at91sam9g45 figure 25-1. at91sam9g45 power management controller block diagram 25.2.1 main application modes the power management controller provides 3 main application modes. 25.2.1.1 normal mode ? plla and upll are running respectively at 400 mhz and 480 mhz ? usb device high speed and host ehci high speed operations are allowed ? full speed ohci input clock is upllck, usbdiv is 9 (division by 10) ? system input clock is pllack, pck is 400 mhz ? mdiv is 11, mck is 133 mhz ? ddr2 can be used at up to 133 mhz 25.2.1.2 usb hs and lp-ddr mode ? only upll is running at 480 mhz, plla power consumption is saved ? usb device high speed and host ehci high speed operations are allowed ? full speed ohci input clock is upllck, usbdiv is 9 (division by 10) ? system input clock is upllck, prescaler is 2, pck is 240 mhz ? mdiv is 01, mck is 120 mhz ? only lp-ddr can be used at up to 120 mhz uhp4 8 m uhp12m s y s clk ddr mck periph_clk[..] int s lck mainck pllack pre s c a ler /1,/2,/4,.../64 pck proce ss or clock controller m as ter clock controller peripher a l s clock controller on/off /1 /2 / 3 /4 s lck mainck pre s c a ler /1,/2,/4,...,/64 progr a mm ab le clock controller pck[..] on/off upllck /1,/2 upllck u s b ohci u s bdiv+1 /4 u s b ehci u s b s divider x /1 /1.5 /2
302 6438fCatarmC21-jun-10 at91sam9g45 25.2.1.3 no udp hs, uhp fs and ddr2 mode ? only plla is running at 384 mhz, upll power consumption is saved ? usb device high speed and host ehci high speed operations are not allowed ? full speed ohci input clock is pllack, usbdiv is 7 (division by 8) ? system input clock is pllack, pck is 384 mhz ? mdiv is 11, mck is 128 mhz ? ddr2 can be used at up to 128 mhz 25.3 master clock controller the master clock controller provides selection and division of the master clock (mck). mck is the clock provided to all the peripherals and the memory controller. the master clock is selected from one of the clocks provided by the clock generator. selecting the slow clock provides a slow clock signal to the whole device. selecting the main clock saves power consumption of the plla. the master clock controller is made up of a cloc k selector and a prescaler. it also contains a master clock divider which allows the processor clock to be faster than the master clock. the master clock selection is made by writi ng the css field (clock source selection) in pmc_mckr (master clock register). the prescaler supports the division by a power of 2 of the selected clock between 1 and 64. the pres field in pmc_mckr programs the prescaler. the master clock divider can be programmed through the mdiv field in pmc_mckr. note: it is forbidden to modify mdiv and css at the same access. each field must be modified sepa- rately with a wait for mckrdy flag between the first field modification and the second field modification. each time pmc_mckr is written to define a ne w master clock, the mckr dy bit is cleared in pmc_sr. it reads 0 until the master clock is es tablished. then, the mckrdy bit is set and can trigger an interrupt to the processor. this feature is useful when switching from a high-speed clock to a lower one to inform the software when the change is actually done. figure 25-2. master clock controller 25.4 processor clock controller the pmc features a processor clock controller (pck) that implements the processor idle mode. the processor clock can be disabled by writing the system clock disable register slck master clock prescaler mck pres css master clock divider mainck pllack mdiv to the processor clock controller (pck) pmc_mckr pmc_mckr pmc_mckr processor clock divider upllck
303 6438fCatarmC21-jun-10 at91sam9g45 (pmc_scdr). the status of this clock (at least for debug purpose) can be read in the system clock status register (pmc_scsr). the processor clock pck is enabled after a reset and is automatically re-enabled by any enabled interrupt. the processor idle mode is ac hieved by disabling the processor clock, which is automatically re-enabled by any enabled fast or normal interrupt, or by the reset of the product. when the processor clock is disabled, the curr ent instruction is finished before the clock is stopped, but this does not prevent data transfers from other masters of the system bus. 25.5 usb device and host clocks the usb device and host high speed ports clocks are contro lled by the udphs and uhphs bits in pmc_pcer. to save power on this peri pheral when they are is not used, the user can set these bits in pmc_pcdr. the udphs and uhphs bits pmc_pcsr gives the activity of these clocks. the pmc also provides the clocks uhp48m and uhp12m to the usb host ohci. the usb host ohci clocks are controlled by the uhp bit in pmc_scer. to save power on this periph- eral when it is not used, the user can set the uhp bit in pmc_scdr. the uhp bit in pmc_scsr gives the activity of this clock. the usb host ohci requires both the 12/48 mhz signal and the master clock. usbdiv field in pmc_usb register is to be programmed to 9 (divi- sion by 10) for normal operations. to save more power consumption user can stop utmi pll, in this case usb high-speed opera- tions are not possible. nevertheless, as the usb ohci input clock can be selected with usbs bit (plla or utmi pll) in pmc_usb register, ohci full-speed operation remain possible. the user must program the usb ohci input clock and the usbdiv divider in pmc_usb regis- ter to generate a 48 mhz and a 12 mhz signal with an accuracy of 0.25%. 25.6 lp-ddr/ddr2 clock the power management controller controls the clo cks of the ddr memory. it provides sysclk ddr internal clock. that clock is used by the ddr controller to provide ddr control, data and ddr clock signals. the ddr clock can be enabled and disabled wit h ddrck bit respectively in pmc_scer and pmc_sder registers. at reset ddr clock is disabled to save power consumption. the input clock is the same as master clo ck. the output sysclk ddr clock is 2xmck. in the case mdiv = 00, pck = mck and sys clk ddr and ddrck clocks are not available. if input clock is pllack/plladiv2 the ddr controller can drive ddr2 and lp-ddr at up to 133mhz with mdiv = 11. to save plla power consumption, the user can choose upllck an input clock for the system. in this case the ddr controller can drive ld- ddr at up to 120mhz.
304 6438fCatarmC21-jun-10 at91sam9g45 25.7 peripheral clock controller the power management controller controls the clocks of each embedded peripheral by the way of the peripheral clock controller. the user can individually enable and disable the master clock on the peripherals by writing into the peripheral clock enable (pmc_pcer) and periph- eral clock disable (pmc_pcdr) registers. the status of the peripheral clock activity can be read in the peripheral clock status register (pmc_pcsr). when a peripheral clock is disabled, the clock is immediately stopped. the peripheral clocks are automatically disabled after a reset. in order to stop a peri pheral, it is recommended that the syst em software wait until the peripheral has executed its last programmed operation before disabling the clock. this is to avoid data cor- ruption or erroneous behavior of the system. the bit number within the peripheral clock control registers (pmc_pcer, pmc_pcdr, and pmc_pcsr) is the peripheral identifier defined at the product level. generally, the bit number corresponds to the interrupt source number assigned to the peripheral. 25.8 programmable clock output controller the pmc controls pmc_prog_clk_nb signals to be output on external pins pckx. each sig- nal can be independently programmed via the pmc_pckx registers. pckx can be independently selected between the slow clock, the master clock, the pllack/plladiv2, the utmi pll output and the main clock by writing the css and cssmck fields in pmc_pckx. each output signal can also be divided by a power of 2 between 1 and 64 by writing the pres (presc aler) field in pmc_pckx. each output signal can be enabled and disabled by writing 1 in the corresponding bit, pckx of pmc_scer and pmc_scdr, respectively. status of the active programmable output clocks are given in the pckx bits of pmc_scsr (system clock status register). moreover, like the pck, a status bit in pmc_sr indicates that the programmable clock is actu- ally what has been programmed in the programmable clock registers. as the programmable clock controller does not manage with glitch prevention when switching clocks, it is strongly recommended to disable the programmable clock before any configuration change and to re-enable it after the change is actually performed. 25.9 programming sequence 1. enabling the 12mhz main oscillator: the main oscillator is enabled by setting the moscen field in the ckgr_mor register. in some cases it may be advantageous to define a start-up time. this can be achieved by writ- ing a value in the oscount field in the ckgr_mor register. once this register has been correctly configured, the user must wait for moscs field in the pmc_sr register to be set. this can be done either by polling th e status register or by wait- ing the interrupt line to be raised if the associated interrupt to moscs has been enabled in the pmc_ier register. 2. setting plla and divider: all parameters needed to configure plla and the divider are located in the ckgr_pllar register.
305 6438fCatarmC21-jun-10 at91sam9g45 the diva field is used to control divider itself. a value between 0 and 255 can be pro- grammed. divider output is divider inpu t divided by diva parameter. by default diva parameter is set to 0 which means that divider is turned off. the outa field is used to select the plla output frequency range. the mula field is the plla multiplier factor. this parameter can be programmed between 0 and 254. if mula is set to 0, plla will be turned off, otherw ise the plla output frequency is plla input frequency multiplied by (mula + 1). the pllacount field specifies the number of slow clock cycles before locka bit is set in the pmc_sr register after ckgr_pllar register has been written. once the pmc_pllar register has been written, the user must wait for the locka bit to be set in the pmc_sr register. this can be done either by polling the status register or by wait- ing the interrupt line to be raised if the associated interrupt to locka has been enabled in the pmc_ier register. all parameters in ckgr_pllar can be programmed in a single write operation. if at some stage one of the following parameters, mula, diva is modified, locka bit will go low to indicate that plla is not ready yet. when plla is locked, locka will be set again. the user is constrained to wait for locka bit to be set before using the plla output clock. code example: write_register(ckgr_pllar,0x00040805) if plla and divider are enabled, the plla input clock is the main clock. plla output clock is plla input clock multiplied by 5. once ck gr_pllar has been written, locka bit will be set after eight slow clock cycles. 3. setting bias and high speed pll (upll) for utmi the utmi pll is enabled by setting the up llen field in the ckgr_uckr register. the utmi bias must is enabled by setting the bia sen field in the ckgr_uckr register in the same time. in some cases it may be advantageous to define a start-up time. this can be achieved by writing a value in the pllcount field in the ckgr_uckr register. once this register has been correctly configur ed, the user must wait for locku field in the pmc_sr register to be set. this can be done either by polling th e status register or by wait- ing the interrupt line to be raised if the associated interrupt to locku has been enabled in the pmc_ier register. 4. selection of master clock and processor clock the master clock and the processor clock are configurable via the pmc_mckr register. the css field is used to select the clock source of the master clock and processor clock dividers. by default, the select ed clock source is slow clock. the pres field is used to control the master/processor clock prescaler. the user can choose between different values (1, 2, 4, 8, 16, 32, 64). prescaler output is the selected clock source divided by pres parameter. by defau lt, pres parameter is set to 1 which means that the input clock of the master clock and processor clock dividers is equal to slow clock.
306 6438fCatarmC21-jun-10 at91sam9g45 the mdiv field is used to control the master clock divider. it is possible to choose between different values (0, 1, 2, 3). the master clock output is master/processor clock prescaler output divided by 1, 2, 4 or 3, depending on the value programmed in mdiv. the plladiv2 field is used to control the plla clock divider. it is possible to choose between different values (0, 1). the pmc plla clock input is divided by 1 or 2, depending on the value programmed in plladiv2. by default, mdiv and pllladiv2 are set to 0, which indicates that pr ocessor clock is equal to the master clock. once the pmc_mckr register has been written, the user must wait for the mckrdy bit to be set in the pmc_sr register. this can be done either by polling the status register or by waiting for the interrupt line to be raised if the associated interrupt to mckrdy has been enabled in the pmc_ier register. the pmc_mckr register must not be programmed in a single write operation. the preferred programming sequence for the pmc_mckr register is as follows: ? if a new value for css field corresponds to plla clock, C program the pres field in the pmc_mckr register. C wait for the mckrdy bit to be set in the pmc_sr register. C program the css field in the pmc_mckr register. C wait for the mckrdy bit to be set in the pmc_sr register. ? if a new value for css field corresponds to main clock or slow clock, C program the css field in the pmc_mckr register. C wait for the mckrdy bit to be set in the pmc_sr register. C program the pres field in the pmc_mckr register. C wait for the mckrdy bit to be set in the pmc_sr register. if at some stage one of the following parameters, css or pres, is modified, the mckrdy bit will go low to indicate that the master clock and the processor clock are not ready yet. the user must wait for mckrdy bit to be set again before using the master and processor clocks. note: if plla clock was selected as the master clock and the user decides to modify it by writing in ckgr_pllar, the mckrdy flag will go low while plla is unlocked. once plla is locked again, lock goes high and mckrdy is set. while plla is unlocked, the master clock select ion is automatically changed to main clock. for further information, see section 25.10.2 . clock switching waveforms on page 309 . code example: write_register(pmc_mckr,0x00000001) wait (mckrdy=1) write_register(pmc_mckr,0x00000011) wait (mckrdy=1) the master clock is main clock divided by 16. the processor clock is the master clock.
307 6438fCatarmC21-jun-10 at91sam9g45 5. selection of programmable clocks programmable clocks are controlled vi a registers; pmc_scer, pmc_scdr and pmc_scsr. programmable clocks can be enabled and/or disabled via the pmc_scer and pmc_scdr registers. depending on the system used, pmc_prog_clk_nb programmable clocks can be enabled or disabled. the pmc_scsr provides a clear indication as to which programma- ble clock is enabled. by default all programmable clocks are disabled. pmc_pckx registers are used to configure programmable clocks. the css and cssmck fields are used to select the programmable clock divider source. five clock options are available: main clock, sl ow clock, master cloc k, pllack, upllck. by default, the clock source selected is slow clock. the pres field is used to control the programmable clock prescaler. it is possible to choose between different values (1, 2, 4, 8, 16, 32, 64). programmable clock output is prescaler input divided by pres parameter. by default, the pres parameter is set to 1 which means that master clock is equal to slow clock. once the pmc_pckx register has been programmed, the corresponding programmable clock must be enabled and the user is constrained to wait for the pckrdyx bit to be set in the pmc_sr register. this can be done either by polling the stat us register or by waiting the interrupt line to be raised if the associated interrupt to pckrdyx has been enabled in the pmc_ier register. all parameters in pmc_pckx can be programmed in a single write operation. if the css and pres parameters are to be modified, the corresponding programmable clock must be disabled first. the parameters can then be modified. once this has been done, the user must re-enable the programmable clock and wait for the pckrdyx bit to be set. code example: write_register(pmc_pck0,0x00000015) programmable clock 0 is main clock divided by 32. 6. enabling peripheral clocks once all of the previous steps have been completed, the peripheral clocks can be enabled and/or disabled via registers pmc_pcer and pmc_pcdr. depending on the system used, 19 peripheral clocks can be enabled or disabled. the pmc_pcsr provides a clear view as to which peripheral clock is enabled. note: each enabled peripheral clock corresponds to master clock. code examples: write_register(pmc_pcer,0x00000110) peripheral clocks 4 and 8 are enabled.
308 6438fCatarmC21-jun-10 at91sam9g45 write_register(pmc_pcdr,0x00000010) peripheral clock 4 is disabled. 25.10 clock switching details 25.10.1 master clock switching timings table 25-1 gives the worst case timings required fo r the master clock to switch from one selected clock to another one. this is in the event that the prescaler is de-activated. when the prescaler is activated, an additional time of 64 clock cycles of the new selected clock has to be added. table 25-1. clock switching timings (worst case) from main clock slck plla clock to main clock C 4 x slck + 2.5 x main clock 3 x plla clock + 4 x slck + 1 x main clock slck 0.5 x main clock + 4.5 x slck C 3 x plla clock + 5 x slck plla clock 0.5 x main clock + 4 x slck + pllacount x slck + 2.5 x pllax clock 2.5 x plla clock + 5 x slck + pllacount x slck 2.5 x plla clock + 4 x slck + pllacount x slck
309 6438fCatarmC21-jun-10 at91sam9g45 25.10.2 clock switching waveforms figure 25-3. switch master clock from slow clock to plla clock figure 25-4. switch master clock from main clock to slow clock slow clock lock mckrdy master clock write pmc_mckr pll clock slow clock main clock mckrdy master clock write pmc_mckr
310 6438fCatarmC21-jun-10 at91sam9g45 figure 25-5. change plla programming figure 25-6. programmable clock output programming main clock main clock pll clock lock mckrdy master clock write ckgr_pllr pll clock pckrdy pckx output write pmc_pckx write pmc_scer write pmc_scdr pckx is disabled pckx is enabled pll clock is selected
311 6438fCatarmC21-jun-10 at91sam9g45 25.11 power management contro ller (pmc) user interface table 25-2. register mapping offset register name access reset value 0x0000 system clock enable register pmc_scer write-only C 0x0004 system clock disable register pmc_scdr write-only C 0x0008 system clock status register pmc _scsr read-only 0x01 0x000c reserved C C C 0x0010 peripheral clock enable register pmc _pcer write-only C 0x0014 peripheral clock disable register pmc_pcdr write-only C 0x0018 peripheral clock status register pmc_pcsr read-only 0x0 0x001c utmi clock register ckgr_uckr read/write 0x1020 0800 0x0020 main oscillator register ckgr_mor read/write 0x0 0x0024 main clock frequency register ckgr_mcfr read-only 0x0 0x0028 plla register ckgr_pllar read/write 0x3f00 0x002c reserved C C C 0x0030 master clock register pmc_mckr read/write 0x0 0x0038 usb clock register pmc_usb read/write 0x0 0x003c reserved C C C 0x0040 programmable clock 0 register pmc_pck0 read/write 0x0 0x0044 programmable clock 1 register pmc_pck1 read/write 0x0 0x0048-0x005c reserved C C C 0x0060 interrupt enable register pmc_ier write-only -- 0x0064 interrupt disable register pmc_idr write-only -- 0x0068 status register pmc_sr read-only 0x08 0x006c interrupt mask register pmc_imr read-only 0x0 0x0070 - 0x007c reserved C C C 0x0080 pll charge pump current register pmc_pllicpr write-only 0x0
312 6438fCatarmC21-jun-10 at91sam9g45 25.11.1 pmc system clock enable register register name: pmc_scer address: 0xfffffc00 access type: write-only ? ddrck: ddr clock enable 0 = no effect. 1 = enables the ddr clock. ? uhp: usb host ohci clocks enable 0 = no effect. 1 = enables the uhp48m and uhp12m ohci clocks. ? pckx: programmable clock x output enable 0 = no effect. 1 = enables the corresponding programmable clock output. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 pck7 pck6 pck5 pck4 pck5 pck4 pck1 pck0 76543210 pck7 uhp C C C ddrck C C
313 6438fCatarmC21-jun-10 at91sam9g45 25.11.2 pmc system clock disable register register name: pmc_scdr address: 0xfffffc04 access type: write-only ? pck: processor clock disable 0 = no effect. 1 = disables the processor clock. this is used to enter the processor in idle mode. ? ddrck: ddr clock disable 0 = no effect. 1 = disables the ddr clock. ? uhp: usb host ohci clock disable 0 = no effect. 1 = disables the uhp48m and uhp12m ohci clocks. ? pckx: programmable clock x output disable 0 = no effect. 1 = disables the corresponding programmable clock output. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 pck7 pck6 pck5 pck4 pck5 pck4 pck1 pck0 76543210 pck7 uhp C C C ddrck C pck
314 6438fCatarmC21-jun-10 at91sam9g45 25.11.3 pmc system clock status register register name: pmc_scsr address: 0xfffffc08 access type: read-only ? pck: processor clock status 0 = the processor clock is disabled. 1 = the processor clock is enabled. ? ddrck: ddr clock status 0 = the ddr clock is disabled. 1 = the ddr clock is enabled. ? uhp: usb host port clock status 0 = the uhp48m and uhp12m ohci clocks are disabled. 1 = the uhp48m and uhp12m ohci clocks are enabled. ? pckx: programmable clock x output status 0 = the corresponding programmable clock output is disabled. 1 = the corresponding programmable clock output is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 pck7 pck6 pck5 pck4 pck5 pck4 pck1 pck0 76543210 pck7 uhp C C C ddrck C pck
315 6438fCatarmC21-jun-10 at91sam9g45 25.11.4 pmc peripheral clock enable register register name: pmc_pcer address: 0xfffffc10 access type: write-only ? pidx: peripheral clock x enable 0 = no effect. 1 = enables the corresponding peripheral clock. note: pid2 to pid31 refer to identifiers as defined in the section peripheral identifiers in the product datasheet. note: programming the control bits of the peripheral id that ar e not implemented has no effect on the behavior of the pmc. 31 30 29 28 27 26 25 24 pid31 pid30 pid29 pid28 pid27 pid26 pid25 pid24 23 22 21 20 19 18 17 16 pid23 pid22 pid21 pid20 pid19 pid18 pid17 pid16 15 14 13 12 11 10 9 8 pid15 pid14 pid13 pid12 pid11 pid10 pid9 pid8 76543210 pid7 pid6 pid5 pid4 pid3 pid2 - -
316 6438fCatarmC21-jun-10 at91sam9g45 25.11.5 pmc peripheral clock disable register register name: pmc_pcdr address: 0xfffffc14 access type: write-only ? pidx: peripheral clock x disable 0 = no effect. 1 = disables the corresponding peripheral clock. note: pid2 to pid31 refer to identifiers as defined in the section peripheral identifiers in the product datasheet. 31 30 29 28 27 26 25 24 pid31 pid30 pid29 pid28 pid27 pid26 pid25 pid24 23 22 21 20 19 18 17 16 pid23 pid22 pid21 pid20 pid19 pid18 pid17 pid16 15 14 13 12 11 10 9 8 pid15 pid14 pid13 pid12 pid11 pid10 pid9 pid8 76543210 pid7 pid6 pid5 pid4 pid3 pid2 - -
317 6438fCatarmC21-jun-10 at91sam9g45 25.11.6 pmc peripheral clock status register register name: pmc_pcsr address: 0xfffffc18 access type: read-only ? pidx: peripheral clock x status 0 = the corresponding peripheral clock is disabled. 1 = the corresponding peripheral clock is enabled. note: pid2 to pid31 refer to identifiers as defined in the section peripheral identifiers in the product datasheet. 31 30 29 28 27 26 25 24 pid31 pid30 pid29 pid28 pid27 pid26 pid25 pid24 23 22 21 20 19 18 17 16 pid23 pid22 pid21 pid20 pid19 pid18 pid17 pid16 15 14 13 12 11 10 9 8 pid15 pid14 pid13 pid12 pid11 pid10 pid9 pid8 76543210 pid7 pid6 pid5 pid4 pid3 pid2 C C
318 6438fCatarmC21-jun-10 at91sam9g45 25.11.7 pmc utmi clock configuration register register name: ckgr_uckr address: 0xfffffc1c access type: read/write ? upllen: utmi pll enable 0 = the utmi pll is disabled. 1 = the utmi pll is enabled. when upllen is set, the locku flag is set on ce the utmi pll startup time is achieved. ? pllcount: utmi pll start-up time specifies the number of slow clock cycles multiplied by 8 for the utmi pll start-up time. ? biasen: utmi bias enable 0 = the utmi bias is disabled. 1 = the utmi bias is enabled. ? biascount: utmi bias start-up time specifies the number of slow clock cycles for the utmi bias start-up time. 31 30 29 28 27 26 25 24 biascount C C C biasen 23 22 21 20 19 18 17 16 pllcount C C C upllen 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCC
319 6438fCatarmC21-jun-10 at91sam9g45 25.11.8 pmc clock generator main oscillator register register name: ckgr_mor address: 0xfffffc20 access type: read/write ? moscen: main oscillator enable a crystal must be connected between xin and xout. 0 = the main oscillator is disabled. 1 = the main oscillator is enabl ed. oscbypass must be set to 0. when moscen is set, the moscs flag is set once the main oscillator startup time is achieved. ? oscbypass: oscillator bypass 0 = no effect. 1 = the main oscillator is bypassed. moscen must be set to 0. an exter nal clock must be connected on xin. when oscbypass is set, th e moscs flag in pmc_sr is automatically set. clearing moscen and oscbypass bits allows resetting the moscs flag. ? oscount: main oscillator start-up time specifies the number of slow clock cycles multip lied by 8 for the main o scillator start-up time. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 oscount 76543210 CCCCCCoscbypassmoscen
320 6438fCatarmC21-jun-10 at91sam9g45 25.11.9 pmc clock generator main clock frequency register register name: ckgr_mcfr address: 0xfffffc24 access type: read-only ? mainf: main clock frequency gives the number of main clock cycles within 16 slow clock periods. ? mainrdy: main clock ready 0 = mainf value is not valid or the main oscillator is disabled. 1 = the main oscillator has been enabled pr eviously and mainf value is available. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCmainrdy 15 14 13 12 11 10 9 8 mainf 76543210 mainf
321 6438fCatarmC21-jun-10 at91sam9g45 25.11.10 pmc clock generator plla register register name: ckgr_pllar address: 0xfffffc28 access type: read/write possible limitations on pll input frequencies and multiplier factors should be checked before using the pmc. warning: bit 29 must always be set to 1 when programming the ckgr_pllar register. ? diva: divider a ? pllacount: plla counter specifies the number of slow clock cycles before the lo cka bit is set in pmc_sr after ckgr_pllar is written. ? outa: plla clock frequency range to optimize clock performance, this field must be programmed as specified in pll characteristics in the electrical char- acteristics section of the product datasheet. ? mula: plla multiplier 0 = the plla is deactivated. 1 up to 254 = the plla clock frequency is the plla input frequency multiplied by mula+ 1. 31 30 29 28 27 26 25 24 CC1CCCCC 23 22 21 20 19 18 17 16 mula 15 14 13 12 11 10 9 8 outa pllacount 76543210 diva diva divider selected 0 divider output is 0 1 divider is bypassed 2 - 255 divider output is the selected clock divided by diva.
322 6438fCatarmC21-jun-10 at91sam9g45 25.11.11 pmc usb clock register register name: pmc_usb address: 0xfffffc38 access type: read/write ? usbs: usb ohci input clock selection 0 = usb clock input is plla 1 = usb clock input is upll ? usbdiv: divider for usb ohci clock. usb clock is input clock divided by usbdiv+1 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCC usbdiv 76543210 CCCCCCCusbs
323 6438fCatarmC21-jun-10 at91sam9g45 25.11.12 pmc master clock register register name: pmc_mckr address: 0xfffffc30 access type: read/write ? css: master/processor clock source selection ? pres: master/processor clock prescaler 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCplladiv2CC mdiv 76543210 C C C pres css css clock source selection 0 0 slow clock is selected. 0 1 main clock is selected. 1 0 plla output clock is selected. 1 1 upll output clock is selected. pres master/processor clock dividers input clock 0 0 0 selected clock 0 0 1 selected clock divided by 2 0 1 0 selected clock divided by 4 0 1 1 selected clock divided by 8 1 0 0 selected clock divided by 16 1 0 1 selected clock divided by 32 1 1 0 selected clock divided by 64 111reserved
324 6438fCatarmC21-jun-10 at91sam9g45 ? mdiv: master clock division note: it is forbidden to modify mdiv and css at the same access. each field must be modified separately with a wait for mckrdy f lag between the first field modification and the second field modification. ? plladiv2: plla divisor by 2 mdiv master clock division 00 master clock is prescaler output clock divided by 1. warning: sysclk ddr and ddrck are not available. 01 master clock is prescaler output clock divided by 2. sysclk ddr is equal to 2 x mck. ddrck is equal to mck. 10 master clock is prescaler output clock divided by 4. sysclk ddr is equal to 2 x mck. ddrck is equal to mck. 11 master clock is prescaler output clock divided by 3. sysclk ddr is equal to 2 x mck. ddrck is equal to mck. plladiv2 plla clock division 0 plla clock frequency is divided by 1. 1 plla clock frequency is divided by 2.
325 6438fCatarmC21-jun-10 at91sam9g45 25.11.13 pmc programmable clock register register name: pmc_pckx address: 0xfffffc40 access type: read/write ? css: master clock selection ? pres: programmable clock prescaler ? slckmck: slow clock or master clock selection 0 = slow clock is selected 1 = master clock is selected to select between slow clock and master clock, the css field must be programmed to 00. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCslckmck 76543210 C C C pres css css clock source selection 00 slow clock or master clock may be selected depending on slckmck field. 0 1 main clock is selected. 1 0 pllack/plladiv2 is selected. 1 1 upllck is selected. pres programmable clock 0 0 0 selected clock 0 0 1 selected clock divided by 2 0 1 0 selected clock divided by 4 0 1 1 selected clock divided by 8 1 0 0 selected clock divided by 16 1 0 1 selected clock divided by 32 1 1 0 selected clock divided by 64 111reserved
326 6438fCatarmC21-jun-10 at91sam9g45 25.11.14 pmc interrupt enable register register name: pmc_ier address: 0xfffffc60 access type: write-only ? moscs: main oscillator status interrupt enable ? locka: pll lock interrupt enable ? mckrdy: master clock ready interrupt enable ? locku: utmi pll lock interrupt enable ? pckrdyx: programmable clock ready x interrupt enable 0 = no effect. 1 = enables the corresponding interrupt. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCpck5pck4pckrdy1pckrdy0 76543210 Clocku C C mckrdy C locka moscs
327 6438fCatarmC21-jun-10 at91sam9g45 25.11.15 pmc interrupt disable register register name: pmc_idr address: 0xfffffc64 access type: write-only ? moscs: main oscillator status interrupt disable ? locka: plla lock interrupt disable ? mckrdy: master clock ready interrupt disable ? locku: utmi pll lock interrupt disable ? pckrdyx: programmable clock ready x interrupt disable 0 = no effect. 1 = disables the corresponding interrupt. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCpck5pck4pckrdy1pckrdy0 76543210 C locku CC mckrdy C locka moscs
328 6438fCatarmC21-jun-10 at91sam9g45 25.11.16 pmc status register register name: pmc_sr address: 0xfffffc68 access type: read-only ? moscs: moscs flag status 0 = main oscillator is not stabilized. 1 = main oscillator is stabilized. ? locka: plla lock status 0 = plla is not locked 1 = plla is locked. ? mckrdy: master clock status 0 = master clock is not ready. 1 = master clock is ready. ? locku: upll lock status 0 = upll is not locked 1 = upll is locked. ? pckrdyx: programmable clock ready status 0 = programmable clock x is not ready. 1 = programmable clock x is ready. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCpck5pck4pckrdy1pckrdy0 76543210 C locku CC mckrdy C locka moscs
329 6438fCatarmC21-jun-10 at91sam9g45 25.11.17 pmc interrupt mask register register name: pmc_imr address: 0xfffffc6c access type: read-only ? moscs: main oscillator status interrupt mask ? locka: plla lock interrupt mask ? mckrdy: master clock ready interrupt mask ? locku: utmi pll lock interrupt mask ? pckrdyx: programmable clock ready x interrupt mask 0 = the corresponding interrupt is enabled. 1 = the corresponding interrupt is disabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCpck5pck4pckrdy1pckrdy0 76543210 C locku CC mckrdy C locka moscs
330 6438fCatarmC21-jun-10 at91sam9g45 25.11.18 pll charge pump current register register name: pmc_pllicpr address: 0xfffffc80 access type: write-only ? icplla: charge pump current to optimize clock performance, this field must be programmed as specified in pll a characteristics in the electrical char- acteristics section of the product datasheet. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCicplla
331 6438fCatarmC21-jun-10 at91sam9g45 26. advanced interrupt controller (aic) 26.1 description the advanced interrupt controller (aic) is an 8-level priority, individually maskable, vectored interrupt controller, providing handling of up to thirty-two interrupt sources. it is designed to sub- stantially reduce the software and real-time overhead in handling internal and external interrupts. the aic drives the nfiq (fast interrupt request) and the nirq (standard interrupt request) inputs of an arm processor. inputs of the aic are either internal peripheral interrupts or external inter- rupts coming from the product's pins. the 8-level priority controller allows the user to define the priority for each interrupt source, thus permitting higher priority interrupts to be serviced even if a lower priority interrupt is being treated. internal interrupt sources can be programmed to be level sensitive or edge triggered. external interrupt sources can be programmed to be positive-edge or negative-edge triggered or high- level or low-level sensitive. the fast forcing feature redirects any internal or external interrupt source to provide a fast inter- rupt rather than a normal interrupt. 26.2 embedded characteristics ? controls the interrupt lines (nirq and nfiq) of the arm processor ? thirty-two individually maskable and vectored interrupt sources C source 0 is reserved for the fast interrupt input (fiq) C source 1 is reserved for system peripherals (pit, rtt, pmc, dbgu, etc.) C programmable edge-triggered or level-sensitive internal sources C programmable positive/negative edge-triggered or high/low level-sensitive ? one external sources plus the fast interrupt signal ? 8-level priority controller C drives the normal interrupt of the processor C handles priority of the interrupt sources 1 to 31 C higher priority interrupts can be served during service of lower priority interrupt ? vectoring C optimizes interrupt service routine branch and execution C one 32-bit vector register per interrupt source C interrupt vector register reads the corresponding current interrupt vector ?protect mode C easy debugging by preventing automatic operations when protect modes are enabled ?fast forcing C permits redirecting any normal interrupt source on the fast interrupt of the processor
332 6438fCatarmC21-jun-10 at91sam9g45 26.3 block diagram figure 26-1. block diagram 26.4 application block diagram figure 26-2. description of the application block 26.5 aic detailed block diagram figure 26-3. aic detailed block diagram aic apb arm processor fiq irq0-irqn embedded peripheralee peripheral embedded peripheral embedded up to thirty-two sources nfiq nirq advanced interrupt controller embedded peripherals external peripherals (external interrupts) standalone applications rtos drivers hard real time tasks os-based applications os drivers general os interrupt handler fiq pio controller advanced interrupt controller irq0-irqn pioirq embedded peripherals external source input stage internal source input stage fast forcing interrupt priority controller fast interrupt controller arm processor nfiq nirq power management controller wake up user interface apb processor clock
333 6438fCatarmC21-jun-10 at91sam9g45 26.6 i/o line description 26.7 product dependencies 26.7.1 i/o lines the interrupt signals fiq and irq0 to irqn are normally multiplexed through the pio control- lers. depending on the features of the pio controller used in the product, the pins must be programmed in accordance with their assigned interrupt function. this is not applicable when the pio controller used in the product is transparent on the input path. 26.7.2 power management the advanced interrupt controller is continuously clocked. the power management controller has no effect on the advanced interrupt controller behavior. the assertion of the advanced interrupt controller outputs, either nirq or nfiq, wakes up the arm processor while it is in idle mode. the general interrupt mask feature enables the aic to wake up the processor without asserting the interr upt line of the processor, thus providing syn- chronization of the processor on an event. 26.7.3 interrupt sources the interrupt source 0 is always located at fiq. if the product does not feature an fiq pin, the interrupt source 0 cannot be used. the interrupt source 1 is always located at system interrupt. this is the result of the or-wiring of the system peripheral interrupt lines. when a system interrupt occurs, the service routine must first distinguish the cause of the interrupt . this is performed by reading successively the status registers of the above mentioned system peripherals. the interrupt sources 2 to 31 can either be connected to the interrupt outputs of an embedded user peripheral or to external interrupt lines . the external interrupt lines can be connected directly, or through the pio controller. the pio controllers are considered as user peripherals in the scope of interrupt handling. accordingly, the pio controller interrupt lines are connected to the interrupt sources 2 to 31. the peripheral identification defined at the product level corresponds to the interrupt source number (as well as the bit number controlling the clock of the peri pheral). conseq uently, to sim- plify the description of the functional operations and the user interface, the interrupt sources are named fiq, sys, and pid2 to pid31. table 26-1. i/o line description pin name pin description type fiq fast interrupt input irq0 - irqn interrupt 0 - interrupt n input table 26-2. i/o lines instance signal i/o line peripheral aic fiq pd19 b aic irq pd18 b
334 6438fCatarmC21-jun-10 at91sam9g45 26.8 functional description 26.8.1 interrupt source control 26.8.1.1 interrupt source mode the advanced interrupt controller independently programs each interrupt source. the src- type field of the corresponding aic_smr (source mode register) selects the interrupt condition of each source. the internal interrupt sources wired on the interrupt outputs of the embedded peripherals can be programmed either in level-sensitive mode or in edge-triggered mode. the active level of the internal interrupts is not important for the user. the external interrupt sources can be programmed either in high level-sensitive or low level-sen- sitive modes, or in positive edge-triggered or negative edge-triggered modes. 26.8.1.2 interrupt source enabling each interrupt source, including the fiq in source 0, can be enabled or disabled by using the command registers; aic_iecr (interrupt enable command register) and aic_idcr (interrupt disable command register). this set of registers conducts enabling or disabling in one instruc- tion. the interrupt mask can be read in the aic_imr register. a disabled interrupt does not affect servicing of other interrupts. 26.8.1.3 interrupt clearing and setting all interrupt sources programmed to be edge-triggered (including the fiq in source 0) can be individually set or cleared by writing respectively the aic_iscr and aic_iccr registers. clear- ing or setting interrupt sources programmed in level-sensitive mode has no effect. the clear operation is perfunctory, as the softwa re must perform an acti on to reinitialize the memorization circuitry activated when the source is programmed in edge-triggered mode. however, the set operation is available for auto-test or software debug purposes. it can also be used to execute an aic-implementation of a software interrupt. the aic features an automatic clear of the current interrupt when the aic_ivr (interrupt vector register) is read. only the interrupt source being detected by the aic as the current interrupt is affected by this operation. ( see priority controller on page 337. ) the automatic clear reduces the operations required by the interrupt service routine entry code to reading the aic_ivr. note that the automatic interrupt clear is disabled if the interrupt source has the fast forcing feature enabled as it is considered uniquely as a fiq source. (for further details, see fast forcing on page 341. ) the automatic clear of the interrupt source 0 is performed when aic_fvr is read. 26.8.1.4 interrupt status for each interrupt, the aic operation originates in aic_ipr (interrupt pending register) and its mask in aic_imr (interrupt mask register). aic_ipr enables the actual activity of the sources, whether masked or not. the aic_isr register reads the number of the current interrupt (see priority controller on page 337 ) and the register aic_cisr gives an image of the signals nirq and nfiq driven on the processor. each status referred to above can be used to optimize the interrupt handling of the systems.
335 6438fCatarmC21-jun-10 at91sam9g45 26.8.1.5 internal interrupt source input stage figure 26-4. internal interrupt source input stage 26.8.1.6 external interrupt source input stage figure 26-5. external interrupt source input stage edge detector clear set source i aic_ipr aic_imr aic_iecr aic_idcr aic_iscr aic_iccr fast interrupt controller or priority controller ff level/ edge aic_smri (srctype) edge detector clear set pos./neg. aic_iscr aic_iccr source i ff level/ edge high/low aic_smri srctype aic_ipr aic_imr aic_iecr aic_idcr fast interrupt controller or priority controller
336 6438fCatarmC21-jun-10 at91sam9g45 26.8.2 interrupt latencies global interrupt latencies depend on several parameters, including: ? the time the software masks the interrupts. ? occurrence, either at the processor level or at the aic level. ? the execution time of the instruction in progress when the interrupt occurs. ? the treatment of higher priority interrupts and the resynchronization of the hardware signals. this section addresses only the hardware resync hronizations. it gives details of the latency times between the event on an external interrupt leading in a valid interrupt (edge or level) or the assertion of an internal interrupt source and the assertion of the nirq or nfiq line on the pro- cessor. the resynchronization time depends on the programming of the interrupt source and on its type (internal or external). for the standard interrupt, resynchronization times are given assuming there is no higher priority in progress. the pio controller multiplexing has no effect on the interrupt latencies of the external interrupt sources. 26.8.2.1 external interrupt edge triggered source figure 26-6. external interrupt edge triggered source 26.8.2.2 external interrupt level sensitive source figure 26-7. external interrupt level sensitive source maximum fiq latency = 4 cycles maximum irq latency = 4 cycles nfiq nirq mck irq or fiq (positive edge) irq or fiq (negative edge) maximum irq latency = 3 cycles maximum fiq latency = 3 cycles mck irq or fiq (high level) irq or fiq (low level) nirq nfiq
337 6438fCatarmC21-jun-10 at91sam9g45 26.8.2.3 internal interrupt edge triggered source figure 26-8. internal interrupt edge triggered source 26.8.2.4 internal interrupt level sensitive source figure 26-9. internal interrupt level sensitive source 26.8.3 normal interrupt 26.8.3.1 priority controller an 8-level priority controller drives the nirq line of the processor, depending on the interrupt conditions occurring on the interrupt sources 1 to 31 (except for those programmed in fast forcing). each interrupt source has a programmable priority le vel of 7 to 0, which is user-definable by writ- ing the prior field of the corresponding aic_smr (source mode register). level 7 is the highest priority and level 0 the lowest. as soon as an interrupt condition occurs, as defined by the srctype field of the aic_smr (source mode register), the nirq line is asserted. as a new interrupt condition might have hap- pened on other interrupt sources since the nirq has been asserted, the priority controller determines the current interrupt at the time the aic_ivr (interrupt vector register) is read. the read of aic_ivr is the entry point of the interrupt handling which allows the aic to consider that the interrupt has been taken into account by the software. the current priority level is defined as the priority level of the current interrupt. if several interrupt sources of equal priority are pending and enabled when the aic_ivr is read, the interrupt with the lowest interrupt source number is serviced first. mck nirq peripheral interrupt becomes active maximum irq latency = 4.5 cycles mck nirq maximum irq latency = 3.5 cycles peripheral interrupt becomes active
338 6438fCatarmC21-jun-10 at91sam9g45 the nirq line can be asserted only if an interrupt cond ition occurs on an in terrupt source with a higher priority. if an interrupt condition happens (or is pending) during the interrupt treatment in progress, it is delayed until the software indicates to the aic the end of the current service by writing the aic_eoicr (end of interrupt command register). the write of aic_eoicr is the exit point of the interrupt handling . 26.8.3.2 interrupt nesting the priority controller utilizes interr upt nesting in order for the high priority interrup t to be handled during the service of lower priori ty interrupts. this requires the interrupt service routines of the lower interrupts to re-enable the interrupt at the processor level. when an interrupt of a higher priority happens during an already occurring interrupt service rou- tine, the nirq line is re-asserted. if the interrupt is enabled at the core level, the current execution is interrupted and the new interrupt service routine should read the aic_ivr. at this time, the current interrupt number and its priority level are pushed into an embedded hardware stack, so that they are saved and restored when the higher priority interrupt servicing is finished and the aic_eoicr is written. the aic is equipped with an 8-leve l wide hardware stack in order to support up to eight interrupt nestings pursuant to having eight priority levels. 26.8.3.3 interrupt vectoring the interrupt handler addresses corresponding to each interrupt source can be stored in the reg- isters aic_svr1 to aic_svr31 (source vector register 1 to 31). when the processor reads aic_ivr (interrupt vector register), the value written into aic_svr corresponding to the cur- rent interrupt is returned. this feature offers a way to branch in one single instruction to the handler corresponding to the current interrupt, as aic_ivr is mapped at the absolute address 0xffff f100 and thus acces- sible from the arm interrupt vector at address 0x0000 0018 through the following instruction: ldr pc,[pc,# -&f20] when the processor executes this instruction, it loads the read value in aic_ivr in its program counter, thus branching the execution on the correct interrupt handler. this feature is often not used when the application is based on an operating system (either real time or not). operating systems often have a single entry point for all the interrupts and the first task performed is to discern the source of the interrupt. however, it is strongly recommended to port the operating system on at91 products by support- ing the interrupt vectoring. this can be performed by defining all the aic_svr of the interrupt source to be handled by the operating system at the address of its interrupt handler. when doing so, the interrupt vectoring permits a critical inte rrupt to transfer the execution on a specific very fast handler and not onto the operating systems general interrupt handler. this facilitates the support of hard real-time tasks (input/outputs of voice/audio buffers and software peripheral han- dling) to be handled efficiently and independently of the application running under an operating system. 26.8.3.4 interrupt handlers this section gives an overview of the fast interrupt handling sequence when using the aic. it is assumed that the programmer understands the architecture of the arm processor, and espe- cially the processor interrupt mode s and the associated status bits.
339 6438fCatarmC21-jun-10 at91sam9g45 it is assumed that: 1. the advanced interrupt controller has been programmed, aic_svr registers are loaded with corresponding interrupt service routine addresses and interrupts are enabled. 2. the instruction at the arm interrupt exception vector address is required to work with the vectoring ldr pc, [pc, # -&f20] when nirq is asserted, if the bit i of cpsr is 0, the sequence is as follows: 1. the cpsr is stored in spsr_i rq, the current value of the program coun ter is loaded in the interrupt link register (r14_irq) and the program counter (r15) is loaded with 0x18. in the following cycle during fetch at address 0x1c, the arm core adjusts r14_irq, dec- rementing it by four. 2. the arm core enters interrupt mode, if it has not already done so. 3. when the instruction loaded at address 0x18 is executed, the program counter is loaded with the value read in aic_ivr. reading the aic_ivr has the following effects: C sets the current interrupt to be the pending and enabled interrupt with the highest priority. the current level is the priority level of the current interrupt. C de-asserts the nirq line on the processor. even if vectoring is not used, aic_ivr must be read in order to de-assert nirq. C automatically clears the interrupt, if it has been programmed to be edge-triggered. C pushes the current level and the current interrupt number on to the stack. C returns the value written in the aic_svr corresponding to the current interrupt. 4. the previous step has the effect of branc hing to the corresponding interrupt service routine. this should start by saving the link register (r14_irq) and spsr_irq. the link register must be decremented by four when it is saved if it is to be restored directly into the program counter at the end of the interrupt. for example, the instruction sub pc, lr, #4 may be used. 5. further interrupts can then be unmasked by clearing the i bit in cpsr, allowing re- assertion of the nirq to be taken into account by the core. this can happen if an inter- rupt with a higher priority than the current interrupt occurs. 6. the interrupt handler can th en proceed as required, savi ng the registers that will be used and restoring them at the end. during this phase, an interrupt of higher priority than the current leve l will restart the sequence from step 1. note: if the interrupt is programmed to be level sensitiv e, the source of the interrupt must be cleared dur- ing this phase. 7. the i bit in cpsr must be set in order to mask interrupts before exiting to ensure that the interrupt is completed in an orderly manner. 8. the end of interrupt command register (aic_eoicr) must be written in order to indi- cate to the aic that the current interrupt is finished. this causes the current level to be popped from the stack, restoring the previous current level if one exists on the stack. if another interrupt is pending, with lower or equal priority than the old current level but with higher priority than the new current level, the nirq line is re-asserted, but the inter- rupt sequence does not immediately start because the i bit is set in the core. spsr_irq is restored. fina lly, the saved value of the link regi ster is restored directly into the pc. this has the effect of returning from the interrupt to whatever was being exe- cuted before, and of loading the cpsr with the stored spsr, masking or unmasking the interrupts depending on the state saved in spsr_irq.
340 6438fCatarmC21-jun-10 at91sam9g45 note: the i bit in spsr is significant. if it is set, it indicates that the arm core was on the verge of masking an interrupt when the mask instruction was in terrupted. hence, when spsr is restored, the mask instruction is comple ted (interrupt is masked). 26.8.4 fast interrupt 26.8.4.1 fast interrupt source the interrupt source 0 is the only source which can raise a fast interrupt request to the processor except if fast forcing is used. the interrupt so urce 0 is generally connected to a fiq pin of the product, either directly or through a pio controller. 26.8.4.2 fast interrupt control the fast interrupt logic of the aic has no priority controller. the mode of interrupt source 0 is programmed with the aic_smr0 and the field prior of this register is not used even if it reads what has been written. the fi eld srctype of aic_smr0 enable s programming the fast inter- rupt source to be positive-edge triggered or negative-edge triggered or high-level sensitive or low-level sensitive writing 0x1 in the aic_iecr (interrupt enable command register) and aic_idcr (interrupt disable command register) respectively enables and disables the fast interrupt. the bit 0 of aic_imr (interrupt mask register) indicates whet her the fast interrupt is enabled or disabled. 26.8.4.3 fast interrupt vectoring the fast interrupt handler address can be stor ed in aic_svr0 (source vector register 0). the value written into this register is returned when the processor reads aic_fvr (fast vector reg- ister). this offers a way to branch in one single instruction to the interrupt handler, as aic_fvr is mapped at the absolute address 0xffff f104 and thus accessible from the arm fast inter- rupt vector at address 0x0000 001c through the following instruction: ldr pc,[pc,# -&f20] when the processor executes this instruction it loads the value read in aic_fvr in its program counter, thus branching the execution on the fast interrupt handler. it also automatically per- forms the clear of the fast interrupt source if it is programmed in edge-triggered mode. 26.8.4.4 fast interrupt handlers this section gives an overview of the fast interrupt handling sequence when using the aic. it is assumed that the programmer understands the architecture of the arm processor, and espe- cially the processor interrupt modes and associated status bits. assuming that: 1. the advanced interrupt controller has been programmed, aic_svr0 is loaded with the fast interrupt service routine address, and the interrupt source 0 is enabled. 2. the instruction at address 0x1c (fiq exception vector address) is required to vector the fast interrupt: ldr pc, [pc, # -&f20] 3. the user does not need nested fast interrupts. when nfiq is asserted, if the bit f of cpsr is 0, the sequence is: 1. the cpsr is stored in spsr_fiq, the current value of the program counter is loaded in the fiq link register (r14_fiq) and the program counter (r15) is loaded with 0x1c. in
341 6438fCatarmC21-jun-10 at91sam9g45 the following cycle, during fetch at address 0x20, the arm core ad justs r14_fiq, decre- menting it by four. 2. the arm core enters fiq mode. 3. when the instruction loaded at address 0x1c is executed, the program counter is loaded with the value read in aic_fvr. re ading the aic_fvr has effect of automati- cally clearing the fast interrupt, if it has been programmed to be edge triggered. in this case only, it de-asserts the nfiq line on the processor. 4. the previous step enables branching to the corresponding interrupt service routine. it is not necessary to save the link register r14_fiq and spsr_fiq if nested fast interrupts are not needed. 5. the interrupt handler can then proceed as required. it is not necessary to save regis- ters r8 to r13 because fiq mode has its own dedicated registers and the user r8 to r13 are banked. the other registers, r0 to r7, must be saved before being used, and restored at the end (before the next step). note that if the fast interrupt is programmed to be level sensitive, the source of the interrupt must be cleared during this phase in order to de-assert the interrupt source 0. 6. finally, the link register r14_fiq is restored into the pc after decrementing it by four (with instruction sub pc, lr, #4 for example). this has the effect of returning from the interrupt to whatever was being exec uted before, loading the cpsr with the spsr and masking or unmasking the fast interrupt depending on the state saved in the spsr. note: the f bit in spsr is significan t. if it is set, it indicates that the arm core was just about to mask fiq interrupts when the mask instru ction was interrupted. hence wh en the spsr is restored, the interrupted instruction is completed (fiq is masked). another way to handle the fast interrupt is to map the interrupt service routine at the address of the arm vector 0x1c. this method does not use the vectoring, so that reading aic_fvr must be performed at the very beginning of the handler operation. however, this method saves the execution of a branch instruction. 26.8.4.5 fast forcing the fast forcing feature of the advanced interrupt controller provides redirection of any normal interrupt source on the fast interrupt controller. fast forcing is enabled or disabl ed by writing to the fast forcing enable register (aic_ffer) and the fast forcing disable register (aic_ff dr). writing to these registers results in an update of the fast forcing status register (aic _ffsr) that controls the feature for each inter- nal or external interrupt source. when fast forcing is disabled, the interrupt sources are handled as described in the previous pages. when fast forcing is enabled, the edge/level programming and, in certain cases, edge detec- tion of the interrupt s ource is still active but the source c annot trigger a normal interrupt to the processor and is not seen by the priority handler. if the interrupt source is programmed in level- sensitive mode and an active level is sampled, fast forcing results in the assertion of the nfiq line to the core. if the interrupt source is programmed in edge-triggered mode and an active edge is detected, fast forcing results in the assertion of the nfiq line to the core. the fast forcing feature does not affect the source 0 pending bit in the interrupt pending reg- ister (aic_ipr).
342 6438fCatarmC21-jun-10 at91sam9g45 the fiq vector register (aic_fvr) reads the contents of the source vector register 0 (aic_svr0), whatever the source of the fast interrupt may be. the read of the fvr does not clear the source 0 when the fast forcing feature is used and the interrupt source should be cleared by writing to the interrupt cl ear command register (aic_iccr). all enabled and pending interrupt sources that have the fast forcing feature enabled and that are programmed in edge-triggered mode must be cleared by writing to the interrupt clear command register. in doing so, they are cleared independently and thus lost interrupts are prevented. the read of aic_ivr does not clear the source that has the fast forcing feature enabled. the source 0, reserved to the fast interrupt, continues operating normally and becomes one of the fast interrupt sources. figure 26-10. fast forcing 26.8.5 protect mode the protect mode permits reading the interrupt vector register without performing the associ- ated automatic operations. this is necessary when working with a debug system. when a debugger, working either with a debug monitor or the arm processor's ic e, stops the applica- tions and updates the opened windows, it might read the aic user interface and thus the ivr. this has undesirable consequences: ? if an enabled interrupt with a higher priority than the current one is pending, it is stacked. ? if there is no enabled pending interrupt, the spurious vector is returned. in either case, an end of interrupt command is necessary to acknowledge and to restore the context of the aic. this operation is generally not performed by the debug system as the debug system would become strongly intrusive and caus e the application to enter an undesired state. this is avoided by using the protect mode. wr iting prot in aic_dcr (debug control register) at 0x1 enables the protect mode. when the protect mode is enabled, the aic performs interrupt stacking only when a write access is performed on the aic_ivr. therefore, the interrupt service routines must write (arbitrary data) to the aic_ivr just after reading it. the new context of the aic, including the value of the interrupt status register (aic_isr), is updated with the current interrupt only when aic_ivr is written. source 0 _ fiq input stage automatic clear input stage automatic clear source n aic_ipr aic_imr aic_ffsr aic_ipr aic_imr priority manager nfiq nirq read ivr if source n is the current interrupt and if fast forcing is disabled on source n. read fvr if fast forcing is disabled on sources 1 to 31.
343 6438fCatarmC21-jun-10 at91sam9g45 an aic_ivr read on its own (e.g., by a debugger), modifies neither the aic context nor the aic_isr. extra aic_ivr reads perform the same operations. however, it is recommended to not stop the processor between the read and the write of aic_ivr of the interrupt service routine to make sure the debugger does not modify the aic context. to summarize, in normal operating mode, the read of aic_ivr performs the following opera- tions within the aic: 1. calculates active interrupt (higher than current or spurious). 2. determines and returns the vector of the active interrupt. 3. memorizes the interrupt. 4. pushes the current priority level onto the internal stack. 5. acknowledges the interrupt. however, while the protect mode is activated, only operations 1 to 3 are performed when aic_ivr is read. operations 4 and 5 are only performed by the aic when aic_ivr is written. software that has been written and debugged using the protect mode runs correctly in normal mode without modification. however, in normal mode the aic_ivr write has no effect and can be removed to optimize the code. 26.8.6 spurious interrupt the advanced interrupt controller features protection against spurious interrupts. a spurious interrupt is defined as being the assertion of an interrupt source long enough for the aic to assert the nirq, but no longer present when aic_ivr is read. this is most prone to occur when: ? an external interrupt source is programmed in level-sensitive mode and an active level occurs for only a short time. ? an internal interrupt source is programmed in level sensitive and the output signal of the corresponding embedded peripheral is activated for a short time. (as in the case for the watchdog.) ? an interrupt occurs just a few cycles before the software begins to mask it, thus resulting in a pulse on the interrupt source. the aic detects a spurious interrupt at the time the aic_ivr is read while no enabled interrupt source is pending. when this happens, the aic returns the value stored by the programmer in aic_spu (spurious vector register). the pr ogrammer must store the address of a spurious interrupt handler in aic_spu as part of the application, to enable an as fast as possible return to the normal execution flow. this handler writes in aic_eoicr and performs a return from interrupt. 26.8.7 general interrupt mask the aic features a general interrupt mask bit to prevent interrupts from reaching the processor. both the nirq and the nfiq lines are driven to thei r inactive state if the bit gmsk in aic_dcr (debug control register) is set. however, this mask does not prevent waking up the processor if it has entered idle mode. this function facilit ates synchronizing the processor on a next event and, as soon as the event occurs, performs subsequent operations without having to handle an interrupt. it is strongly recommended to use this mask with caution.
344 6438fCatarmC21-jun-10 at91sam9g45 26.9 advanced interrupt controll er (aic) user interface 26.9.1 base address the aic is mapped at the address 0xffff f000 . it has a total 4-kbyte addressing space. this permits the vectoring fea- ture, as the pc-relative load/store instructions of the arm processor support only a 4-kbyte offset. notes: 1. the reset value of this register depends on the level of the external interrupt source. all other sources are cleared a t reset, thus not pending. 2. pid2...pid31 bit fields refer to the identifiers as defined in the peripheral identifiers section of the product datasheet. 3. values in the version register vary with the version of the ip block implementation. table 26-3. register mapping offset register name access reset 0x00 source mode register 0 aic_smr0 read-write 0x0 0x04 source mode register 1 aic_smr1 read-write 0x0 --- --- --- --- --- 0x7c source mode register 31 aic_smr31 read-write 0x0 0x80 source vector register 0 aic_svr0 read-write 0x0 0x84 source vector register 1 aic_svr1 read-write 0x0 --- --- --- --- --- 0xfc source vector register 31 aic_svr31 read-write 0x0 0x100 interrupt vector register aic_ivr read-only 0x0 0x104 fiq interrupt vector register aic_fvr read-only 0x0 0x108 interrupt status register aic_isr read-only 0x0 0x10c interrupt pending register (2) aic_ipr read-only 0x0 (1) 0x110 interrupt mask register (2) aic_imr read-only 0x0 0x114 core interrupt status register aic_cisr read-only 0x0 0x118 - 0x11c reserved --- --- --- 0x120 interrupt enable command register (2) aic_iecr write-only --- 0x124 interrupt disable command register (2) aic_idcr write-only --- 0x128 interrupt clear command register (2) aic_iccr write-only --- 0x12c interrupt set command register (2) aic_iscr write-only --- 0x130 end of interrupt command register aic_eoicr write-only --- 0x134 spurious interrupt vector register aic_spu read-write 0x0 0x138 debug control register aic_dcr read-write 0x0 0x13c reserved --- --- --- 0x140 fast forcing enable register (2) aic_ffer write-only --- 0x144 fast forcing disable register (2) aic_ffdr write-only --- 0x148 fast forcing status register (2) aic_ffsr read-only 0x0 0x14c - 0x1e0 reserved --- --- --- 0x1ec - 0x1fc reserved
345 6438fCatarmC21-jun-10 at91sam9g45 26.9.2 aic source mode register register name: aic_smr0..aic_smr31 address: 0xfffff000 access type: read-write reset value: 0x0 ? prior: priority level programs the priority level for all sources except fiq source (source 0). the priority level can be between 0 (lowest) and 7 (highest). the priority level is not used for the fi q in the related smr register aic_smrx. ? srctype: interrupt source type the active level or edge is not programmable for the internal interrupt sources. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C srctype C C prior srctype internal interrupt sources external interrupt sources 0 0 high level sensitive low level sensitive 0 1 positive edge triggered negative edge triggered 1 0 high level sensitive high level sensitive 1 1 positive edge triggered positive edge triggered
346 6438fCatarmC21-jun-10 at91sam9g45 26.9.3 aic source vector register register name: aic_svr0..aic_svr31 address: 0xfffff080 access type: read-write reset value: 0x0 ? vector: source vector the user may store in these registers the addresses of the corresponding handler for each interrupt source. 26.9.4 aic interrupt vector register register name: aic_ivr address: 0xfffff100 access type: read-only reset value: 0x0 ? irqv: interrupt vector register the interrupt vector register contains the vector programmed by the user in the source vector register corresponding to the current interrupt. the source vector register is indexed using the current interrupt number when the interrupt vector register is read. when there is no current interrupt, the interrupt vector register reads the value stored in aic_spu. 31 30 29 28 27 26 25 24 vector 23 22 21 20 19 18 17 16 vector 15 14 13 12 11 10 9 8 vector 76543210 vector 31 30 29 28 27 26 25 24 irqv 23 22 21 20 19 18 17 16 irqv 15 14 13 12 11 10 9 8 irqv 76543210 irqv
347 6438fCatarmC21-jun-10 at91sam9g45 26.9.5 aic fiq vector register register name: aic_fvr address: 0xfffff104 access type: read-only reset value: 0x0 ? fiqv: fiq vector register the fiq vector register contains the vector programmed by the user in the source vector register 0. when there is no fast interrupt, the fiq vector register reads the value stored in aic_spu. 26.9.6 aic interrupt status register register name: aic_isr address: 0xfffff108 access type: read-only reset value: 0x0 ? irqid: current interrupt identifier the interrupt status register returns the current interrupt source number. 31 30 29 28 27 26 25 24 fiqv 23 22 21 20 19 18 17 16 fiqv 15 14 13 12 11 10 9 8 fiqv 76543210 fiqv 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCC irqid
348 6438fCatarmC21-jun-10 at91sam9g45 26.9.7 aic interrupt pending register register name: aic_ipr address: 0xfffff10c access type: read-only reset value: 0x0 ? fiq, sys, pid2-pid31: interrupt pending 0 = corresponding interrupt is not pending. 1 = corresponding interrupt is pending. 26.9.8 aic interrupt mask register register name: aic_imr address: 0xfffff110 access type: read-only reset value: 0x0 ? fiq, sys, pid2-pid31: interrupt mask 0 = corresponding interrupt is disabled. 1 = corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 pid31 pid30 pid29 pid28 pid27 pid26 pid25 pid24 23 22 21 20 19 18 17 16 pid23 pid22 pid21 pid20 pid19 pid18 pid17 pid16 15 14 13 12 11 10 9 8 pid15 pid14 pid13 pid12 pid11 pid10 pid9 pid8 76543210 pid7 pid6 pid5 pid4 pid3 pid2 sys fiq 31 30 29 28 27 26 25 24 pid31 pid30 pid29 pid28 pid27 pid26 pid25 pid24 23 22 21 20 19 18 17 16 pid23 pid22 pid21 pid20 pid19 pid18 pid17 pid16 15 14 13 12 11 10 9 8 pid15 pid14 pid13 pid12 pid11 pid10 pid9 pid8 76543210 pid7 pid6 pid5 pid4 pid3 pid2 sys fiq
349 6438fCatarmC21-jun-10 at91sam9g45 26.9.9 aic core interrupt status register register name: aic_cisr address: 0xfffff114 access type: read-only reset value: 0x0 ? nfiq: nfiq status 0 = nfiq line is deactivated. 1 = nfiq line is active. ? nirq: nirq status 0 = nirq line is deactivated. 1 = nirq line is active. 26.9.10 aic interrupt enable command register register name: aic_iecr address: 0xfffff120 access type: write-only ? fiq, sys, pid2-pid31: interrupt enable 0 = no effect. 1 = enables corresponding interrupt. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCnirqnfiq 31 30 29 28 27 26 25 24 pid31 pid30 pid29 pid28 pid27 pid26 pid25 pid24 23 22 21 20 19 18 17 16 pid23 pid22 pid21 pid20 pid19 pid18 pid17 pid16 15 14 13 12 11 10 9 8 pid15 pid14 pid13 pid12 pid11 pid10 pid9 pid8 76543210 pid7 pid6 pid5 pid4 pid3 pid2 sys fiq
350 6438fCatarmC21-jun-10 at91sam9g45 26.9.11 aic interrupt disable command register register name: aic_idcr address: 0xfffff124 access type: write-only ? fiq, sys, pid2-pid31: interrupt disable 0 = no effect. 1 = disables corresponding interrupt. 26.9.12 aic interrupt clear command register register name: aic_iccr address: 0xfffff128 access type: write-only ? fiq, sys, pid2-pid31: interrupt clear 0 = no effect. 1 = clears corresponding interrupt. 31 30 29 28 27 26 25 24 pid31 pid30 pid29 pid28 pid27 pid26 pid25 pid24 23 22 21 20 19 18 17 16 pid23 pid22 pid21 pid20 pid19 pid18 pid17 pid16 15 14 13 12 11 10 9 8 pid15 pid14 pid13 pid12 pid11 pid10 pid9 pid8 76543210 pid7 pid6 pid5 pid4 pid3 pid2 sys fiq 31 30 29 28 27 26 25 24 pid31 pid30 pid29 pid28 pid27 pid26 pid25 pid24 23 22 21 20 19 18 17 16 pid23 pid22 pid21 pid20 pid19 pid18 pid17 pid16 15 14 13 12 11 10 9 8 pid15 pid14 pid13 pid12 pid11 pid10 pid9 pid8 76543210 pid7 pid6 pid5 pid4 pid3 pid2 sys fiq
351 6438fCatarmC21-jun-10 at91sam9g45 26.9.13 aic interrupt set command register register name: aic_iscr address: 0xfffff12c access type: write-only ? fiq, sys, pid2-pid31: interrupt set 0 = no effect. 1 = sets corresponding interrupt. 26.9.14 aic end of interrupt command register register name: aic_eoicr address: 0xfffff130 access type: write-only the end of interrupt command register is used by the interrupt routine to indicate that the interrupt treatment is complete. any value can be written because it is only necessary to make a write to this register location to signal the end of interrupt treatment. 31 30 29 28 27 26 25 24 pid31 pid30 pid29 pid28 pid27 pid26 pid25 pid24 23 22 21 20 19 18 17 16 pid23 pid22 pid21 pid20 pid19 pid18 pid17 pid16 15 14 13 12 11 10 9 8 pid15 pid14 pid13 pid12 pid11 pid10 pid9 pid8 76543210 pid7 pid6 pid5 pid4 pid3 pid2 sys fiq 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCC
352 6438fCatarmC21-jun-10 at91sam9g45 26.9.15 aic spurious interrupt vector register register name: aic_spu address: 0xfffff134 access type: read-write reset value: 0x0 ? sivr: spurious interrupt vector register the user may store the address of a spurious interrupt handler in this register. the written value is returned in aic_ivr in case of a spurious interrupt and in aic_fvr in case of a spurious fast interrupt. 26.9.16 aic debug control register register name: aic_dcr address: 0xfffff138 access type: read-write reset value: 0x0 ? prot: protection mode 0 = the protection mode is disabled. 1 = the protection mode is enabled. ? gmsk: general mask 0 = the nirq and nfiq lines are normally controlled by the aic. 1 = the nirq and nfiq lines are tied to their inactive state. 31 30 29 28 27 26 25 24 sivr 23 22 21 20 19 18 17 16 sivr 15 14 13 12 11 10 9 8 sivr 76543210 sivr 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCgmskprot
353 6438fCatarmC21-jun-10 at91sam9g45 26.9.17 aic fast forcing enable register register name: aic_ffer address: 0xfffff140 access type: write-only ? sys, pid2-pid31: fast forcing enable 0 = no effect. 1 = enables the fast forcing feature on the corresponding interrupt. 26.9.18 aic fast forcing disable register register name: aic_ffdr address: 0xfffff144 access type: write-only ? sys, pid2-pid31: fast forcing disable 0 = no effect. 1 = disables the fast forcing feature on the corresponding interrupt. 31 30 29 28 27 26 25 24 pid31 pid30 pid29 pid28 pid27 pid26 pid25 pid24 23 22 21 20 19 18 17 16 pid23 pid22 pid21 pid20 pid19 pid18 pid17 pid16 15 14 13 12 11 10 9 8 pid15 pid14 pid13 pid12 pid11 pid10 pid9 pid8 76543210 pid7 pid6 pid5 pid4 pid3 pid2 sys C 31 30 29 28 27 26 25 24 pid31 pid30 pid29 pid28 pid27 pid26 pid25 pid24 23 22 21 20 19 18 17 16 pid23 pid22 pid21 pid20 pid19 pid18 pid17 pid16 15 14 13 12 11 10 9 8 pid15 pid14 pid13 pid12 pid11 pid10 pid9 pid8 76543210 pid7 pid6 pid5 pid4 pid3 pid2 sys C
354 6438fCatarmC21-jun-10 at91sam9g45 26.9.19 aic fast forcing status register register name: aic_ffsr address: 0xfffff148 access type: read-only ? sys, pid2-pid31: fast forcing status 0 = the fast forcing feature is disabled on the corresponding interrupt. 1 = the fast forcing feature is enabled on the corresponding interrupt. 31 30 29 28 27 26 25 24 pid31 pid30 pid29 pid28 pid27 pid26 pid25 pid24 23 22 21 20 19 18 17 16 pid23 pid22 pid21 pid20 pid19 pid18 pid17 pid16 15 14 13 12 11 10 9 8 pid15 pid14 pid13 pid12 pid11 pid10 pid9 pid8 76543210 pid7 pid6 pid5 pid4 pid3 pid2 sys C
355 6438fCatarmC21-jun-10 at91sam9g45 27. debug unit (dbgu) 27.1 description the debug unit provides a single entry point from the processor for access to all the debug capabilities of atmels arm-based systems. the debug unit features a two-pin uart that can be used for several debug and trace purposes and offers an ideal medium for in-situ programming solutions and debug monitor communica- tions. the debug unit two-pin uart can be used stand-alone for general purpose serial communication. moreover, the association with two peripheral data controller channels permits packet handling for these tasks with processor time reduced to a minimum. the debug unit also makes the debug communication channel (dcc) signals provided by the in-circuit emulator of the arm processor visible to the software. these signals indicate the sta- tus of the dcc read and write registers and gener ate an interrup t to the arm processor, making possible the handling of the dcc under interrupt control. chip identifier registers permit recognition of t he device and its revision. these registers inform as to the sizes and types of the on-chip memori es, as well as the set of embedded peripherals. finally, the debug unit features a force ntrst capability that enables the software to decide whether to prevent access to the system via th e in-circuit emulator. th is permits protection of the code, stored in rom. 27.2 embedded characteristics ? composed of two functions Ctwo-pin uart C debug communication channel (dcc) support ?two-pin uart C implemented features are 100% compatible with the standard atmel usart C independent receiver and transmitter with a common programmable baud rate generator C even, odd, mark or space parity generation C parity, framing and overrun error detection C automatic echo, local loopback and remote loopback channel modes C support for two pdc channels with connection to receiver and transmitter ? debug communication channel support C offers visibility of an interrupt trigger from commrx and commtx signals from the arm processors ice interface
356 6438fCatarmC21-jun-10 at91sam9g45 27.3 block diagram figure 27-1. debug unit functional block diagram figure 27-2. debug unit application example peripheral dma controller baud rate generator dcc handler ice access handler transmit receive chip id interrupt control peripheral bridge parallel input/ output dtxd drxd power management controller arm processor force_ntrst commrx commtx mck ntrst power-on reset dbgu_irq apb debug unit table 27-1. debug unit pin description pin name description type drxd debug receive data input dtxd debug transmit data output debug unit rs232 drivers programming tool trace console debug console boot program debug monitor trace manager
357 6438fCatarmC21-jun-10 at91sam9g45 27.4 product dependencies 27.4.1 i/o lines depending on product integration, the debug unit pins may be multiplexed with pio lines. in this case, the programmer must first configure the corresponding pio controller to enable i/o lines operations of the debug unit. 27.4.2 power management depending on product integration, the debug unit clock may be controllable through the power management controller. in this case, the programmer must first configure the pmc to enable the debug unit clock. usually, the peripheral identifier used for this purpose is 1. 27.4.3 interrupt source depending on product integration, the debug unit interrupt line is connected to one of the inter- rupt sources of the advanced interrupt controller. interrupt handling requires programming of the aic before configuring the de bug unit. usually, the debug unit interrupt line connects to the interrupt source 1 of the aic, which may be shared with the real-time clock, the system timer interrupt lines and other system peripheral interrupts, as shown in figure 27-1 . this sharing requires the programmer to determine the source of the interrupt when the source 1 is triggered. 27.5 uart operations the debug unit operates as a uart, (asynchro nous mode only) and supports only 8-bit charac- ter handling (with parity). it has no clock pin. the debug unit's uart is made up of a receiver and a transmitter that operate independently, and a common baud rate generator. receiver timeout and transmitter time guard are not imple- mented. however, all the implemented features are compatible with those of a standard usart. 27.5.1 baud rate generator the baud rate generator provides the bit period clock named baud rate clock to both the receiver and the transmitter. the baud rate clock is the master clock divided by 16 times the value (cd) written in dbgu_brgr (baud rate generator register). if dbgu_brgr is set to 0, the baud rate clock is disabled and the debug unit's uart remains inactive. the maximum allowable baud rate is master clock divided by 16. the minimum allow able baud rate is master clock divided by (16 x 65536). table 27-2. i/o lines instance signal i/o line peripheral dbgu drxd pb12 a dbgu dtxd pb13 a baud rate mck 16 cd --------------------- =
358 6438fCatarmC21-jun-10 at91sam9g45 figure 27-3. baud rate generator 27.5.2 receiver 27.5.2.1 receiver rese t, enable and disable after device reset, the debug unit receiver is disabled and must be enabled before being used. the receiver can be enabled by writing the control register dbgu_cr with the bit rxen at 1. at this command, the receiver starts looking for a start bit. the programmer can disable the receiver by writ ing dbgu_cr with the bit rxdis at 1. if the receiver is waiting for a start bit, it is immedi ately stopped. however, if the receiver has already detected a start bit and is receiving the data, it waits for the stop bit before actually stopping its operation. the programmer can also put the receiver in it s reset state by writing dbgu_cr with the bit rstrx at 1. in doing so, the receiver immediat ely stops its current operations and is disabled, whatever its current state. if rstrx is applied wh en data is being processed, this data is lost. 27.5.2.2 start detection and data sampling the debug unit only supports asynchronous operations, and this affects only its receiver. the debug unit receiver detects the start of a rece ived character by sampling the drxd signal until it detects a valid start bit. a low level (space) on drxd is interpreted as a valid start bit if it is detected for more than 7 cycles of the sampling clock, which is 16 times the baud rate. hence, a space that is longer than 7/16 of the bit period is detected as a valid start bit. a space which is 7/16 of a bit period or shorter is ignored and the receiver continues to wait for a valid start bit. when a valid start bit has been detected, the receiver samples the drxd at the theoretical mid- point of each bit. it is assumed that each bit last s 16 cycles of the sampling clock (1-bit period) so the bit sampling point is eight cycles (0.5-bit period) after the start of the bit. the first sampling point is therefore 24 cycles (1.5 -bit periods) after t he falling edge of the st art bit was detected. each subsequent bit is sampled 16 cycles (1-bit period) after the previous one. mck 16-bit counter 0 baud rate clock cd cd out divide by 16 0 1 >1 receiver sampling clock
359 6438fCatarmC21-jun-10 at91sam9g45 figure 27-4. start bit detection figure 27-5. character reception 27.5.2.3 receiver ready when a complete character is received, it is transferred to the dbgu_rhr and the rxrdy sta- tus bit in dbgu_sr (status register) is set. the bit rxrdy is automatically cleared when the receive holding register dbgu_rhr is read. figure 27-6. receiver ready 27.5.2.4 receiver overrun if dbgu_rhr has not been read by the software (o r the peripheral data controller) since the last transfer, the rxrdy bit is still set and a ne w character is received, the ovre status bit in dbgu_sr is set. ovre is cleared when the soft ware writes the contro l register dbgu_cr with the bit rststa (reset status) at 1. figure 27-7. receiver overrun 27.5.2.5 parity error each time a character is received, the receiver calculates the parity of the received data bits, in accordance with the field par in dbgu_mr. it then compares the result with the received parity sampling clock drxd true start detection d0 baud rate clock d0 d1 d2 d3 d4 d5 d6 d7 drxd true start detection sampling parity bit stop bit example: 8-bit, parity enabled 1 stop 1 bit period 0.5 bit period d0 d1 d2 d3 d4 d5 d6 d7 p s s d0 d1 d2 d3 d4 d5 d6 d7 p drxd read dbgu_rhr rxrdy d0 d1 d2 d3 d4 d5 d6 d7 p s s d0 d1 d2 d3 d4 d5 d6 d7 p drxd rststa rxrdy ovre stop stop
360 6438fCatarmC21-jun-10 at91sam9g45 bit. if different, the parity error bit pare in dbgu_sr is set at the same time the rxrdy is set. the parity bit is cleared when the control register dbgu_cr is written with the bit rststa (reset status) at 1. if a new character is received before the reset status command is written, the pare bit remains at 1. figure 27-8. parity error 27.5.2.6 receiver framing error when a start bit is detected, it generates a character reception when all the data bits have been sampled. the stop bit is also sampled and when it is detected at 0, the frame (framing error) bit in dbgu_sr is set at the same time the rxrdy bit is set. the bit frame remains high until the control register dbgu_cr is written with the bit rststa at 1. figure 27-9. receiver framing error 27.5.3 transmitter 27.5.3.1 transmitter reset, enable and disable after device reset, the debug unit transmitter is disabled and it must be enabled before being used. the transmitter is enabled by writing the control register dbgu_cr with the bit txen at 1. from this command, the transmitter waits for a ch aracter to be written in the transmit holding register dbgu_thr before actually starting the transmission. the programmer can disable the transmitter by writing dbgu_cr with the bit txdis at 1. if the transmitter is not operating, it is immediately stopped. however, if a character is being pro- cessed into the shift register and/or a character has been written in the transmit holding register, the characters are completed before the transmitter is actually stopped. the programmer can also put the transmitter in its reset state by writing the dbgu_cr with the bit rsttx at 1. this immediately stops the transmitter, whether or not it is processing characters. 27.5.3.2 transmit format the debug unit transmitter drives the pin dtxd at the baud rate clock speed. the line is driven depending on the format defined in the mode register and the data stored in the shift register. one start bit at level 0, then the 8 data bits, from the lowest to the highest bit, one optional parity bit and one stop bit at 1 are consecutively shifte d out as shown on the following figure. the field stop d0 d1 d2 d3 d4 d5 d6 d7 p s drxd rststa rxrdy pare wrong parity bit d0 d1 d2 d3 d4 d5 d6 d7 p s drxd rststa rxrdy frame stop bit detected at 0 stop
361 6438fCatarmC21-jun-10 at91sam9g45 pare in the mode register dbgu_mr defines whether or not a parity bit is shifted out. when a parity bit is enabled, it can be selected between an odd parity, an even parity, or a fixed space or mark bit. figure 27-10. character transmission 27.5.3.3 transmitter control when the transmitter is enabled, the bit txrdy (transmitter ready) is set in the status register dbgu_sr. the transmission starts when the prog rammer writes in the transmit holding regis- ter dbgu_thr, and after the written character is transferred from dbgu_thr to the shift register. the bit txrdy remains high until a second character is written in dbgu_thr. as soon as the first character is completed, the last character written in dbgu_thr is transferred into the shift register and txrdy rises again, showing that the holding register is empty. when both the shift register and the dbgu_thr are empty, i.e., all the characters written in dbgu_thr have been processed, the bit txempty rises after the last stop bit has been completed. figure 27-11. transmitter control 27.5.4 peripheral data controller both the receiver and the transmitter of the debug unit's uart are generally connected to a peripheral data controller (pdc) channel. the peripheral data controller channels are programmed via registers that are mapped within the debug unit user interface from the offset 0x100. the status bits are reported in the debug unit status register dbgu_sr and can generate an interrupt. d0 d1 d2 d3 d4 d5 d6 d7 dtxd start bit parity bit stop bit example: parity enabled baud rate clock dbgu_thr shift register dtxd txrdy txempty data 0 data 1 data 0 data 0 data 1 data 1 s s p p write data 0 in dbgu_thr write data 1 in dbgu_thr stop stop
362 6438fCatarmC21-jun-10 at91sam9g45 the rxrdy bit triggers the pdc channel data transfer of the receiver. this results in a read of the data in dbgu_rhr. the txrdy bit triggers t he pdc channel data tran sfer of the transmit- ter. this results in a writ e of a data in dbgu_thr. 27.5.5 test modes the debug unit supports three tests modes. these modes of operation are programmed by using the field chmode (channel mode) in the mode register dbgu_mr. the automatic echo mode allows bit-by-bit retr ansmission. when a bit is received on the drxd line, it is sent to the dtxd line. the transm itter operates normally, but has no effect on the dtxd line. the local loopback mode allows the transmitted characters to be received. dtxd and drxd pins are not used and the output of the transmitter is internally connected to the input of the receiver. the drxd pin level has no effect and th e dtxd line is held high , as in idle state. the remote loopback mode directly connects the drxd pin to the dtxd line. the transmitter and the receiver are disabled and have no effec t. this mode allows a bit-by-bit retransmission. figure 27-12. test modes 27.5.6 debug communication channel support the debug unit handles the signals commrx and commtx that come from the debug com- munication channel of the arm processor and are driven by the in-circuit emulator. receiver transmitter disabled rxd txd receiver transmitter disabled rxd txd v dd disabled receiver transmitter disabled rxd txd disabled automatic echo local loopback remote loopback v dd
363 6438fCatarmC21-jun-10 at91sam9g45 the debug communication channel contains two registers that are accessible through the ice breaker on the jtag side and through the coprocessor 0 on the arm processor side. as a reminder, the following instructions ar e used to read and write the debug communication channel: mrc p14, 0, rd, c1, c0, 0 returns the debug communication data read register into rd mcr p14, 0, rd, c1, c0, 0 writes the value in rd to the debug communication data write register. the bits commrx and commtx, which indicate, respectively, that the read register has been written by the debugger but not yet read by the processor, and that the write register has been written by the processor and not yet read by the debugger, are wired on the two highest bits of the status register dbgu_sr. these bits can generate an interrupt. this feature permits han- dling under interrupt a debug link between a debug monitor running on the target system and a debugger. 27.5.7 chip identifier the debug unit features two chip identifier registers, dbgu_cidr (chip id register) and dbgu_exid (extension id). both registers contain a hard-wired value that is read-only. the first register contains the following fields: ? ext - shows the use of the extension identifier register ? nvptyp and nvpsiz - identifies the type of embedded non-volatile memory and its size ? arch - identifies the set of embedded peripherals ? sramsiz - indicates the size of the embedded sram ? eproc - indicates the embedded arm processor ? version - gives the revision of the silicon the second register is device-dependent and reads 0 if the bit ext is 0. 27.5.8 ice access prevention the debug unit allows blockage of access to the system through the arm processor's ice interface. this feature is implemented via th e register force ntrst (dbgu_fnr), that allows assertion of the ntrst signal of the ice interface. writing the bit fntrst (force ntrst) to 1 in this register prevents any activity on the tap controller. on standard devices, the bit fntrst resets to 0 and thus does not prevent ice access. this feature is especially useful on custom rom devices for customers who do not want their on-chip code to be visible.
364 6438fCatarmC21-jun-10 at91sam9g45 27.6 debug unit (dbgu) user interface table 27-3. register mapping offset register name access reset 0x0000 control register dbgu_cr write-only C 0x0004 mode register dbgu_mr read-write 0x0 0x0008 interrupt enable register dbgu_ier write-only C 0x000c interrupt disable register dbgu_idr write-only C 0x0010 interrupt mask register dbgu_imr read-only 0x0 0x0014 status register dbgu_sr read-only C 0x0018 receive holding register dbgu_rhr read-only 0x0 0x001c transmit holding register dbgu_thr write-only C 0x0020 baud rate generator register dbgu_brgr read-write 0x0 0x0024 - 0x003c reserved C C C 0x0040 chip id register dbgu_cidr read-only C 0x0044 chip id extension register dbgu_exid read-only C 0x0048 force ntrst register dbgu_fnr read-write 0x0 0x0100 - 0x0124 pdc area C C C
365 6438fCatarmC21-jun-10 at91sam9g45 27.6.1 debug unit control register name: dbgu_cr address: 0xffffee00 access type: write-only ? rstrx: reset receiver 0 = no effect. 1 = the receiver logic is reset and disabled. if a ch aracter is being received, the reception is aborted. ? rsttx: reset transmitter 0 = no effect. 1 = the transmitter logic is reset and disabled. if a character is being transmitted, the transmission is aborted. ? rxen: receiver enable 0 = no effect. 1 = the receiver is enabled if rxdis is 0. ? rxdis: receiver disable 0 = no effect. 1 = the receiver is disabled. if a character is being processe d and rstrx is not set, the character is completed before the receiver is stopped. ? txen: transmitter enable 0 = no effect. 1 = the transmitter is ena bled if txdis is 0. ? txdis: transmitter disable 0 = no effect. 1 = the transmitter is disabled. if a character is bei ng processed and a character has been written the dbgu_thr and rsttx is not set, both characters are completed before the transmitter is stopped. ? rststa: reset status bits 0 = no effect. 1 = resets the status bits pare, frame and ovre in the dbgu_sr. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCC rststa 76543210 txdis txen rxdis rxen rsttx rstrx CC
366 6438fCatarmC21-jun-10 at91sam9g45 27.6.2 debug unit mode register name: dbgu_mr address: 0xffffee04 access type: read-write ? par: parity type ? chmode: channel mode 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 chmode CC pa r C 76543210 CCCCCCCC par parity type 0 0 0 even parity 001odd parity 0 1 0 space: parity forced to 0 0 1 1 mark: parity forced to 1 1 x x no parity chmode mode description 00normal mode 0 1 automatic echo 1 0 local loopback 1 1 remote loopback
367 6438fCatarmC21-jun-10 at91sam9g45 27.6.3 debug unit interrupt enable register name: dbgu_ier address: 0xffffee08 access type: write-only ? rxrdy: enable rxrdy interrupt ? txrdy: enable txrdy interrupt ? endrx: enable end of receive transfer interrupt ? endtx: enable end of transmit interrupt ? ovre: enable overrun error interrupt ? frame: enable framing error interrupt ? pare: enable parity error interrupt ? txempty: enable txempty interrupt ? txbufe: enable buffer empty interrupt ? rxbuff: enable buffer full interrupt ? commtx: enable commtx (from arm) interrupt ? commrx: enable commrx (from arm) interrupt 0 = no effect. 1 = enables the corresponding interrupt. 31 30 29 28 27 26 25 24 commrx commtx CCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCC rxbuff txbufe C txempty C 76543210 pare frame ovre endtx endrx C txrdy rxrdy
368 6438fCatarmC21-jun-10 at91sam9g45 27.6.4 debug unit interrupt disable register name: dbgu_idr address: 0xffffee0c access type: write-only ? rxrdy: disable rxrdy interrupt ? txrdy: disable txrdy interrupt ? endrx: disable end of receive transfer interrupt ? endtx: disable end of transmit interrupt ? ovre: disable overrun error interrupt ? frame: disable framing error interrupt ? pare: disable parity error interrupt ? txempty: disable txempty interrupt ? txbufe: disable buffer empty interrupt ? rxbuff: disable buffer full interrupt ? commtx: disable commtx (from arm) interrupt ? commrx: disable commrx (from arm) interrupt 0 = no effect. 1 = disables the corresponding interrupt. 31 30 29 28 27 26 25 24 commrx commtx CCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCC rxbuff txbufe C txempty C 76543210 pare frame ovre endtx endrx C txrdy rxrdy
369 6438fCatarmC21-jun-10 at91sam9g45 27.6.5 debug unit interrupt mask register name: dbgu_imr address: 0xffffee10 access type: read-only ? rxrdy: mask rxrdy interrupt ? txrdy: disable txrdy interrupt ? endrx: mask end of receive transfer interrupt ? endtx: mask end of transmit interrupt ? ovre: mask overrun error interrupt ? frame: mask framing error interrupt ? pare: mask parity error interrupt ? txempty: mask txempty interrupt ? txbufe: mask txbufe interrupt ? rxbuff: mask rxbuff interrupt ? commtx: mask commtx interrupt ? commrx: mask commrx interrupt 0 = the corresponding interrupt is disabled. 1 = the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 commrx commtx CCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCC rxbuff txbufe C txempty C 76543210 pare frame ovre endtx endrx C txrdy rxrdy
370 6438fCatarmC21-jun-10 at91sam9g45 27.6.6 debug unit status register name: dbgu_sr address: 0xffffee14 access type: read-only ? rxrdy: receiver ready 0 = no character has been received since the last re ad of the dbgu_rhr or the receiver is disabled. 1 = at least one complete character has been received, transferred to dbgu_rhr and not yet read. ? txrdy: transmitter ready 0 = a character has been written to dbgu_thr and not yet transferred to the shift register, or the transmitter is disabled. 1 = there is no character written to dbgu_thr not yet transferred to the shift register. ? endrx: end of receiver transfer 0 = the end of transfer signal from the receiver peripheral data controller channel is inactive. 1 = the end of transfer signal from the receiver peripheral data controller channel is active. ? endtx: end of transmitter transfer 0 = the end of transfer signal from the transmitter peripheral data controller channel is inactive. 1 = the end of transfer signal from the transmitter peripheral data controller channel is active. ? ovre: overrun error 0 = no overrun error has occurred since the last rststa. 1 = at least one overrun error has occurred since the last rststa. ? frame: framing error 0 = no framing error has occurred since the last rststa. 1 = at least one framing error has occurred since the last rststa. ? pare: parity error 0 = no parity error has occurred since the last rststa. 1 = at least one parity error has occurred since the last rststa. ? txempty: transmitter empty 0 = there are characters in dbgu_thr, or characters being processed by the transmitter, or the transmitter is disabled. 1 = there are no characters in dbgu_thr and there ar e no characters being processed by the transmitter. 31 30 29 28 27 26 25 24 commrx commtx CCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCC rxbuff txbufe C txempty C 76543210 pare frame ovre endtx endrx C txrdy rxrdy
371 6438fCatarmC21-jun-10 at91sam9g45 ? txbufe: transmission buffer empty 0 = the buffer empty signal from the transmitter pdc channel is inactive. 1 = the buffer empty signal from the transmitter pdc channel is active. ? rxbuff: receive buffer full 0 = the buffer full signal from the receiver pdc channel is inactive. 1 = the buffer full signal from the receiver pdc channel is active. ? commtx: debug communication channel write status 0 = commtx from the arm processor is inactive. 1 = commtx from the arm processor is active. ? commrx: debug communication channel read status 0 = commrx from the arm processor is inactive. 1 = commrx from the arm processor is active.
372 6438fCatarmC21-jun-10 at91sam9g45 27.6.7 debug unit receiver holding register name: dbgu_rhr address: 0xffffee18 access type: read-only ? rxchr: received character last received character if rxrdy is set. 27.6.8 debug unit transmit holding register name: dbgu_thr address: 0xffffee1c access type: write-only ? txchr: character to be transmitted next character to be transmitted after the current character if txrdy is not set. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 rxchr 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 txchr
373 6438fCatarmC21-jun-10 at91sam9g45 27.6.9 debug unit baud ra te generator register name: dbgu_brgr address: 0xffffee20 access type: read-write ? cd: clock divisor 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 cd 76543210 cd cd baud rate clock 0 disabled 1mck 2 to 65535 mck / (cd x 16)
374 6438fCatarmC21-jun-10 at91sam9g45 27.6.10 debug unit chip id register name: dbgu_cidr address: 0xffffee40 access type: read-only ? version: version of the device values depend upon the version of the device. ? eproc: embedded processor ? nvpsiz: nonvolatile program memory size 31 30 29 28 27 26 25 24 ext nvptyp arch 23 22 21 20 19 18 17 16 arch sramsiz 15 14 13 12 11 10 9 8 nvpsiz2 nvpsiz 76543210 eproc version eproc processor 0 0 1 arm946es 0 1 0 arm7tdmi 100arm920t 1 0 1 arm926ejs nvpsiz size 0000none 00018k bytes 001016k bytes 001132k bytes 0100reserved 010164k bytes 0110reserved 0111128k bytes 1000reserved 1001256k bytes 1010512k bytes 1011reserved 11001024k bytes
375 6438fCatarmC21-jun-10 at91sam9g45 ? nvpsiz2 second nonvolatile program memory size ? sramsiz: internal sram size 1101reserved 11102048k bytes 1111reserved nvpsiz2 size 0000none 00018k bytes 001016k bytes 001132k bytes 0100reserved 010164k bytes 0110reserved 0111128k bytes 1000reserved 1001256k bytes 1010512k bytes 1011reserved 11001024k bytes 1101reserved 11102048k bytes 1111reserved sramsiz size 0000reserved 00011k bytes 00102k bytes 00116k bytes 0100112k bytes 01014k bytes 011080k bytes 0111160k bytes 10008k bytes 100116k bytes 101032k bytes 101164k bytes nvpsiz size
376 6438fCatarmC21-jun-10 at91sam9g45 ? arch: architecture identifier ? nvptyp: nonvolatile program memory type 1100128k bytes 1101256k bytes 111096k bytes 1111512k bytes arch architecture hex bin 0x19 0001 1001 at91sam9xx series 0x29 0010 1001 at91sam9xexx series 0x34 0011 0100 at91x34 series 0x37 0011 0111 cap7 series 0x39 0011 1001 cap9 series 0x3b 0011 1011 cap11 series 0x40 0100 0000 at91x40 series 0x42 0100 0010 at91x42 series 0x55 0101 0101 at91x55 series 0x60 0110 0000 at91sam7axx series 0x61 0110 0001 at91sam7aqxx series 0x63 0110 0011 at91x63 series 0x70 0111 0000 at91sam7sxx series 0x71 0111 0001 at91sam7xcxx series 0x72 0111 0010 at91sam7sexx series 0x73 0111 0011 at91sam7lxx series 0x75 0111 0101 at91sam7xxx series 0x92 1001 0010 at91x92 series 0xf0 1111 0000 at75cxx series nvptyp memory 000rom 0 0 1 romless or on-chip flash 1 0 0 sram emulating rom 0 1 0 embedded flash memory 011 rom and embedded flash memory nvpsiz is rom size nvpsiz2 is flash size sramsiz size
377 6438fCatarmC21-jun-10 at91sam9g45 ? ext: extension flag 0 = chip id has a single register definition without extension 1 = an extended chip id exists.
378 6438fCatarmC21-jun-10 at91sam9g45 27.6.11 debug unit chip id extension register name: dbgu_exid address: 0xffffee44 access type: read-only ? exid: chip id extension reads 0 if the bit ext in dbgu_cidr is 0. 27.6.12 debug unit force ntrst register name: dbgu_fnr address: 0xffffee48 access type: read-write ? fntrst: force ntrst 0 = ntrst of the arm processors tap controller is driven by the power_on_reset signal. 1 = ntrst of the arm processors tap controller is held low. 31 30 29 28 27 26 25 24 exid 23 22 21 20 19 18 17 16 exid 15 14 13 12 11 10 9 8 exid 76543210 exid 31 30 29 28 27 26 25 24 CCCCCCC C 23 22 21 20 19 18 17 16 CCCCCCC C 15 14 13 12 11 10 9 8 CCCCCCC C 7654321 0 CCCCCCC fntrst
379 6438fCatarmC21-jun-10 at91sam9g45 28. error corrected co de controller (ecc) 28.1 description nand flash/smartmedia devices contain by default invalid blocks which have one or more invalid bits. over the nand flash/smartmedia lifetime, additional invalid blocks may occur which can be detected/corrected by ecc code. the ecc controller is a mechanism that encodes data in a manner that makes possible the identification and correction of certain errors in data. the ecc controller is capable of single bit error correction and 2-bit random detection. w hen nand flash/smartmedia have more than 2 bits of errors, the data cannot be corrected. the ecc user interfac e is compliant with the arm adv anced peripheral bus (apb rev2). 28.2 block diagram figure 28-1. block diagram 28.3 functional description a page in nand flash and smartmedia memories contains an area for main data and an addi- tional area used for redundancy (ecc). the page is organized in 8-bit or 16-bit words. the page size corresponds to the number of words in the main area plus the number of words in the extra area used for redundancy. over time, some memory locations may fail to program or erase properly. in order to ensure that data is stored properly over the life of the nand flash device, nand flash providers recom- user interface ctrl/ecc algorithm static memory controller apb nand flash smartmedia logic ecc controller
380 6438fCatarmC21-jun-10 at91sam9g45 mend to utilize either 1 ecc per 256 bytes of data, 1 ecc per 512 bytes of data or 1 ecc for all of the page. the only configurations required for ecc are the nand flash or the smartmedia page size (528/2112/4224) and the type of correction wanted (1 ecc for all the page/1 ecc per 256 bytes of data /1 ecc per 512 bytes of data). page size is configured setting the pagesize field in the ecc mode register (ecc_mr). type of correction is configured setting the typecorrect field in the ecc mode register (ecc_mr). ecc is automatically computed as soon as a read (00h)/write (80h) command to the nand flash or the smartmedia is detected. read and write access must start at a page boundary. ecc results are available as soon as the counte r reaches the end of the main area. values in the ecc parity registers (ecc_pr0 to ecc_pr15) are then valid and locked until a new start condition occurs (read/write command followed by address cycles). 28.3.1 write access once the flash memory page is written, the computed ecc codes are available in the ecc par- ity (ecc_pr0 to ecc_pr15) registers. the ecc code values must be written by the software application in the extra area used for redundancy. the number of write accesses in the extra area is a function of the value of the type of correction field. for example, for 1 ecc per 256 bytes of data for a page of 512 bytes, only the values of ecc_pr0 and ecc_pr1 must be writ- ten by the software application. other registers are meaningless. 28.3.2 read access after reading the whole data in the main area, the application must perform read accesses to the extra area where ecc code has been previously stored. error detection is automatically per- formed by the ecc controller. please note that it is mandatory to read consecutively the entire main area and the locations where parity and nparity values have been previously stored to let the ecc controller perform error detection. the application can check the ecc status registers (ecc_sr1/ecc_sr2) for any detected errors. it is up to the application to correct any detected error. ecc computation can detect four different circumstances: ? no error: xor between the ecc computation and the ecc code stored at the end of the nand flash or smartmedia page is equal to 0. no error flags in the ecc status registers (ecc_sr1/ecc_sr2). ? recoverable error: only the recerr flags in the ecc status registers (ecc_sr1/ecc_sr2) are set. the corrupted word offset in the read page is defined by the wordaddr field in the ecc parity registers (ecc_pr0 to ecc_pr15). the corrupted bit position in the concerned word is defined in the bitaddr field in the ecc parity registers (ecc_pr0 to ecc_pr15). ? ecc error: the eccerr flag in the ecc status registers (ecc_sr1/ecc_sr2) are set. an error has been detected in the ecc code stored in the flash memory. the position of the corrupted bit can be found by the application performing an xor between the parity and the nparity contained in the ecc code stored in the flash memory. ? non correctable error: the mulerr flag in the ecc status registers (ecc_sr1/ecc_sr2) are set. several unrecoverable errors have been detected in the flash memory page.
381 6438fCatarmC21-jun-10 at91sam9g45 ecc status registers, ecc parity registers are cleared when a read/write command is detected or a software reset is performed. for single-bit error correction and double-bit er ror detection (sec-ded) hsiao code is used. 24-bit ecc is generated in order to perform one bit correction per 256 or 512 bytes for pages of 512/2048/4096 8-bit words. 32-bit ecc is generated in order to perform one bit correction per 512/1024/2048/4096 8- or 16-bit words.they are generated according to the schemes shown in figure 28-2 and figure 28-3 . figure 28-2. parity generation for 512/1024/2048/4096 8-bit words to calculate p8 to px and p8 to px, apply the algorithm that follows. page size = 2 n for i =0 to n begin for (j = 0 to page_size_byte) begin if(j[i] ==1) p[2 i+3 ]=bit7(+)bit6(+)bit5(+)bit4(+)bit3(+) bit2(+)bit1(+)bit0(+)p[2 i+3 ] else p[2 i+3 ]?=bit7(+)bit6(+)bit5(+)bit4(+)bit3(+) bit2(+)bit1(+)bit0(+)p[2 i+3 ]' end end bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 p8' bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 p8 p8' p16 p16' bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 p8 p8' bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 p8 p8' p16 p16' p32 p32 1st byte p32 2nd byte 3rd byte 4 th byte page size th byte (page size -1 )th byte px px' page size = 512 px = 2048 page size = 1024 px = 4096 page size = 2048 px = 8192 page size = 4096 px = 16384 (page size -2 )th byte (page size -3 )th byte p1 p1' p1' p1 p1 p1' p1' p1 p2 p2' p2 p2' p4 p4' p1=bit7(+)bit5(+)bit3(+)bit1(+)p1 p2=bit7(+)bit6(+)bit3(+)bit2(+)p2 p4=bit7(+)bit6(+)bit5(+)bit4(+)p4 p1'=bit6(+)bit4(+)bit2(+)bit0(+)p1' p2' bit5( )bit4( )bit1( )bit0( )p2'
382 6438fCatarmC21-jun-10 at91sam9g45 figure 28-3. parity generation for 512/1024/2048/4096 16-bit words 1st word 2nd word 3rd word 4th word (page size -3 )th word (page size -2 )th word (page size -1 )th word page size th word (+) (+)
383 6438fCatarmC21-jun-10 at91sam9g45 to calculate p8 to px and p8 to px, apply the algorithm that follows. page size = 2 n for i =0 to n begin for (j = 0 to page_size_word) begin if(j[i] ==1) p[2 i+3 ]= bit15(+)bit14(+)bit13(+)bit12(+) bit11(+)bit10(+)bit9(+)bit8(+) bit7(+)bit6(+)bit5(+)bit4(+)bit3(+) bit2(+)bit1(+)bit0(+)p[2 n+3 ] else p[2 i+3 ]?=bit15(+)bit14(+)bit13(+)bit12(+) bit11(+)bit10(+)bit9(+)bit8(+) bit7(+)bit6(+)bit5(+)bit4(+)bit3(+) bit2(+)bit1(+)bit0(+)p[2 i+3 ]' end end
384 6438fCatarmC21-jun-10 at91sam9g45 28.4 error corrected code cont roller (ecc) user interface table 28-1. register mapping offset register name access reset 0x00 ecc control register ecc_cr write-only 0x0 0x04 ecc mode register ecc_mr read-write 0x0 0x08 ecc status1 register ecc_sr1 read-only 0x0 0x0c ecc parity register 0 ecc_pr0 read-only 0x0 0x10 ecc parity register 1 ecc_pr1 read-only 0x0 0x14 ecc status2 register ecc_sr2 read-only 0x0 0x18 ecc parity 2 ecc_pr2 read-only 0x0 0x1c ecc parity 3 ecc_pr3 read-only 0x0 0x20 ecc parity 4 ecc_pr4 read-only 0x0 0x24 ecc parity 5 ecc_pr5 read-only 0x0 0x28 ecc parity 6 ecc_pr6 read-only 0x0 0x2c ecc parity 7 ecc_pr7 read-only 0x0 0x30 ecc parity 8 ecc_pr8 read-only 0x0 0x34 ecc parity 9 ecc_pr9 read-only 0x0 0x38 ecc parity 10 ecc_pr10 read-only 0x0 0x3c ecc parity 11 ecc_pr11 read-only 0x0 0x40 ecc parity 12 ecc_pr12 read-only 0x0 0x44 ecc parity 13 ecc_pr13 read-only 0x0 0x48 ecc parity 14 ecc_pr14 read-only 0x0 0x4c ecc parity 15 ecc_pr15 read-only 0x0
385 6438fCatarmC21-jun-10 at91sam9g45 28.4.1 ecc control register name: ecc_cr access type: write-only ? rst: reset parity provides reset to current ecc by software. 1: reset ecc parity registers 0: no effect ? srst: soft reset provides soft reset to ecc block 1: resets all registers. 0: no effect. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCsrstrst
386 6438fCatarmC21-jun-10 at91sam9g45 28.4.2 ecc mode register register name : ecc_mr access type : read-write ? pagesize: page size this field defines the page size of the nand flash device. a word has a value of 8 bits or 16 bits, depending on the nand flash or smartmedia memory organization. ? typecorrect: type of correction 00: 1 bit correction for a page size of 512/1024/2048/4096 bytes. 01: 1 bit correction for 256 bytes of data for a page size of 512/2048/4096 bytes. 10: 1 bit correction for 512 bytes of data for a page size of 512/2048/4096 bytes. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C typecorrect C C pagesize page size description 00 528 words 01 1056 words 10 2112 words 11 4224 words
387 6438fCatarmC21-jun-10 at91sam9g45 28.4.3 ecc status register 1 register name : ecc_sr1 access type : read-only ? recerr0: recoverable error 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correctable error was detected. otherwise multiple uncorrected errors were detected. ? eccerr0: ecc error 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. if typecorrect = 0, read both ecc parity 0 and ecc parity 1 registers, the error occurred at the location which con- tains a 1 in the least significant 16 bits; else read ecc parity 0 register, the error occurred at the location which contains a 1 in the least significant 24 bits. ? mulerr0: multiple error 0 = no multiple errors detected. 1 = multiple errors detected. ? recerr1: recoverable error in the page between the 256th and the 511th bytes or the 512th and the 1023rd bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correctable error was detected. otherwise multiple uncorrected errors were detected. ? eccerr1: ecc error in the page between the 256th and the 511th bytes or the 512th and the 1023rd bytes fixed to 0 if typecorrec = 0 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 1 register, the error occurred at the lo cation which contains a 1 in the least significant 24 bits. ? mulerr1: multiple error in the page between the 256th and the 511th bytes or the 512th and the 1023rd bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected. 31 30 29 28 27 26 25 24 C mulerr7 eccerr7 recerr7 C mulerr6 eccerr6 recerr6 23 22 21 20 19 18 17 16 C mulerr5 eccerr5 recerr5 C mulerr4 eccerr4 recerr4 15 14 13 12 11 10 9 8 C mulerr3 eccerr3 recerr3 C mulerr2 eccerr2 recerr2 76543210 C mulerr1 eccerr1 recerr1 C mulerr0 eccerr0 recerr0
388 6438fCatarmC21-jun-10 at91sam9g45 ? recerr2: recoverable error in the page between the 512th and the 767th bytes or the 1024th and the 1535th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correct able error was detected. otherwise, multiple uncorrected errors were detected. ? eccerr2: ecc error in the page between the 512th and the 767th bytes or the 1024th and the 1535th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 2 register, the error occurred at the lo cation which contains a 1 in the least significant 24 bits. ? mulerr2: multiple error in the page between the 512th and the 767th bytes or the 1024th and the 1535th bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected. ? recerr3: recoverable error in the page between the 768th and the 1023rd bytes or the 1536th and the 2047th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correctable error was detected. otherwise multiple uncorrected errors were detected. ? eccerr3: ecc error in the page between the 768th and the 1023rd bytes or the 1536th and the 2047th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 3 register, the error occurred at the lo cation which contains a 1 in the least significant 24 bits. ? mulerr3: multiple error in the page between the 768th and the 1023rd bytes or the 1536th and the 2047th bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected. ? recerr4: recoverable error in the page between the 1024th and the 1279th bytes or the 2048th and the 2559th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correctable error was detected. otherwise multiple uncorrected errors were detected.
389 6438fCatarmC21-jun-10 at91sam9g45 ? eccerr4: ecc error in the page between the 1024th and the 1279th bytes or the 2048th and the 2559th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 4 register, the error occurred at the lo cation which contains a 1 in the least significant 24 bits. ? mulerr4: multiple error in the page between the 1024th and the 1279th bytes or the 2048th and the 2559th bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected. ? recerr5: recoverable error in the page between the 1280th and the 1535th bytes or the 2560th and the 3071st bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correctable error was detected. otherwise multiple uncorrected errors were detected ? eccerr5: ecc error in the page between the 1280th and the 1535th bytes or the 2560th and the 3071st bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 5 register, the error occurred at the lo cation which contains a 1 in the least significant 24 bits. ? mulerr5: multiple error in the page between the 1280th and the 1535th bytes or the 2560th and the 3071st bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected. ? recerr6: recoverable error in the page between the 1536th and the 1791st bytes or the 3072nd and the 3583rd bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correctable error was detected. otherwise multiple uncorrected errors were detected. ? eccerr6: ecc error in the page between the 1536th and the 1791st bytes or the 3072nd and the 3583rd bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 6 register, the error occurred at the lo cation which contains a 1 in the least significant 24 bits.
390 6438fCatarmC21-jun-10 at91sam9g45 ? mulerr6: multiple error in the page between the 1536th and the 1791st bytes or the 3072nd and the 3583rd bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected. ? recerr7: recoverable error in the page between the 1792nd and the 2047th bytes or the 3584th and the 4095th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correct able error was detected. otherwise, multiple uncorrected errors were detected. ? eccerr7: ecc error in the page between the 1792nd and the 2047th bytes or the 3584th and the 4095th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 7 register, the error occurred at the lo cation which contains a 1 in the least significant 24 bits. ? mulerr7: multiple error in the page between the 1792nd and the 2047th bytes or the 3584th and the 4095th bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected.
391 6438fCatarmC21-jun-10 at91sam9g45 28.4.4 ecc status register 2 register name : ecc_sr2 access type : read-only ? recerr8: recoverable error in the page between the 2048th and the 2303rd bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correctable error was detected. otherwise multiple uncorrected errors were detected ? eccerr8: ecc error in the page between the 2048th and the 2303rd bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 8 register, the error occurred at the lo cation which contains a 1 in the least significant 24 bits. ? mulerr8: multiple error in the page between the 2048th and the 2303rd bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected. ? recerr9: recoverable error in the page between the 2304th and the 2559th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correctable error was detected. otherwise multiple uncorrected errors were detected. ? eccerr9: ecc error in the page between the 2304th and the 2559th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 9 register, the error occurred at the lo cation which contains a 1 in the least significant 24 bits. ? mulerr9: multiple error in the page between the 2304th and the 2559th bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 31 30 29 28 27 26 25 24 C mulerr15 eccerr15 recerr15 C mulerr14 eccerr14 recerr14 23 22 21 20 19 18 17 16 C mulerr13 eccerr13 recerr13 C mulerr12 eccerr12 recerr12 15 14 13 12 11 10 9 8 C mulerr11 eccerr11 recerr11 C mulerr10 eccerr10 recerr10 76543210 C mulerr9 eccerr9 recerr9 C mulerr8 eccerr8 recerr8
392 6438fCatarmC21-jun-10 at91sam9g45 1 = multiple errors detected. ? recerr10: recoverable error in the page between the 2560th and the 2815th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correct able error was detected. otherwise, multiple uncorrected errors were detected. ? eccerr10: ecc error in the page between the 2560th and the 2815th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 10 register, the error occurred at the location which contains a 1 in the least significant 24 bits. ? mulerr10: multiple error in the page between the 2560th and the 2815th bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected. ? recerr11: recoverable error in the page between the 2816th and the 3071st bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correct able error was detected. otherwise, multiple uncorrected errors were detected ? eccerr11: ecc error in the page between the 2816th and the 3071st bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 11 register, the error occurred at the location which contains a 1 in the least significant 24 bits. ? mulerr11: multiple error in the page between the 2816th and the 3071st bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected. ? recerr12: recoverable error in the page between the 3072nd and the 3327th bytes fixed to 0 if typecorrec = 0 0 = no errors detected 1 = errors detected. if mul_error is 0, a single correctable error was detected. otherwise multiple uncorrected errors were detected ? eccerr12: ecc error in the page between the 3072nd and the 3327th bytes fixed to 0 if typecorrec = 0
393 6438fCatarmC21-jun-10 at91sam9g45 0 = no errors detected 1 = a single bit error occurred in the ecc bytes. read ecc parity 12 register, the error occurred at the location which contains a 1 in the least significant 24 bits. ? mulerr12: multiple error in the page between the 3072nd and the 3327th bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected. ? recerr13: recoverable error in the page between the 3328th and the 3583rd bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correctable error was detected. otherwise multiple uncorrected errors were detected. ? eccerr13: ecc error in the page between the 3328th and the 3583rd bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 13 register, the error occurred at the location which contains a 1 in the least significant 24 bits. ? mulerr13: multiple error in the page between the 3328th and the 3583rd bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected. ? recerr14: recoverable error in the page between the 3584th and the 3839th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correct able error was detected. otherwise, multiple uncorrected errors were detected. ? eccerr14: ecc error in the page between the 3584th and the 3839th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 14 register, the error occurred at the location which contains a 1 in the least significant 24 bits. ? mulerr14: multiple error in the page between the 3584th and the 3839th bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected.
394 6438fCatarmC21-jun-10 at91sam9g45 ? recerr15: recoverable error in the page between the 3840th and the 4095th bytes fixed to 0 if typecorrec = 0. 0 = no errors detected. 1 = errors detected. if mul_error is 0, a single correct able error was detected. otherwise, multiple uncorrected errors were detected ? eccerr15: ecc error in the page between the 3840th and the 4095th bytes fixed to 0 if typecorrec = 0 0 = no errors detected. 1 = a single bit error occurred in the ecc bytes. read ecc parity 15 register, the error occurred at the location which contains a 1 in the least significant 24 bits. ? mulerr15: multiple error in the page between the 3840th and the 4095th bytes fixed to 0 if typecorrec = 0. 0 = no multiple errors detected. 1 = multiple errors detected.
395 6438fCatarmC21-jun-10 at91sam9g45 28.5 registers for 1 ecc for a page of 512/1024/2048/4096 bytes 28.5.1 ecc parity register 0 register name : ecc_pr0 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr: bit address during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr: word address during a page read, this value contains the word address (8-bit or 16-bit word depending on the memory plane organiza- tion) where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 wordaddr 76543210 wordaddr bitaddr
396 6438fCatarmC21-jun-10 at91sam9g45 28.5.2 ecc parity register 1 register name : ecc_pr1 access type : read-only ? nparity: parity n 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 nparity 76543210 nparity
397 6438fCatarmC21-jun-10 at91sam9g45 28.6 registers for 1 ecc per 512 bytes for a page of 512/2048/4 096 bytes, 8-bit word 28.6.1 ecc parity register 0 register name : ecc_pr0 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr0: corrupted bit address in the page between the first byte and the 511th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr0: corrupted word address in the page between the first byte and the 511th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity0: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 nparity0 15 14 13 12 11 10 9 8 nparity0 wordadd0 7 6 543210 wordaddr0 bitaddr0
398 6438fCatarmC21-jun-10 at91sam9g45 28.6.2 ecc parity register 1 register name : ecc_pr1 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr1: corrupted bit address in the page between the 512th an d the 1023rd bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr1: corrupted word address in the pa ge between the 512th and the 1023rd bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity1: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 nparity1 15 14 13 12 11 10 9 8 nparity1 wordadd1 7 6 543210 wordaddr1 bitaddr1
399 6438fCatarmC21-jun-10 at91sam9g45 28.6.3 ecc parity register 2 register name : ecc_pr2 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr2: corrupted bit address in the page between the 1023rd and the 1535th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr2: corrupted word address in the page in the page between the 1023 rd and the 1535th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity2: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 nparity2 15 14 13 12 11 10 9 8 nparity2 wordaddr2 7 6 543210 wordaddr2 bitaddr2
400 6438fCatarmC21-jun-10 at91sam9g45 28.6.4 ecc parity register 3 register name : ecc_pr3 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr3: corrupted bit address in the pa ge between th e1536th and th e 2047th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr3 corrupted word address in the pa ge between the 1536th and the 20 47th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity3 parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 nparity3 15 14 13 12 11 10 9 8 nparity3 wordaddr3 7 6 543210 wordaddr3 bitaddr3
401 6438fCatarmC21-jun-10 at91sam9g45 28.6.5 ecc parity register 4 register name : ecc_pr4 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr4: corrupted bit address in the page between the 2048th and the 2559th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr4: corrupted word address in the page between the 2048th and the 2559th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity4: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 nparity4 15 14 13 12 11 10 9 8 nparity4 wordaddr4 7 6 543210 wordaddr4 bitaddr4
402 6438fCatarmC21-jun-10 at91sam9g45 28.6.6 ecc parity register 5 register name : ecc_pr5 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr5: corrupted bit address in the page between the 2560th and the 3071st bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr5: corrupted word address in the page between the 2560th and the 3071st bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity5: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 nparity5 15 14 13 12 11 10 9 8 nparity5 wordaddr5 7 6 543210 wordaddr5 bitaddr5
403 6438fCatarmC21-jun-10 at91sam9g45 28.6.7 ecc parity register 6 register name : ecc_pr6 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr6: corrupted bit address in the page between the 3072nd an d the 3583rd bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr6: corrupted word address in the pa ge between the 3072nd and the 3583rd bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity6: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 nparity6 15 14 13 12 11 10 9 8 nparity6 wordaddr6 7 6 543210 wordaddr6 bitaddr6
404 6438fCatarmC21-jun-10 at91sam9g45 28.6.8 ecc parity register 7 register name : ecc_pr7 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr7: corrupted bit address in the page between the 3584h an d the 4095th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr7: corrupted word address in the page between the 3584th and the 4095th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity7: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 nparity7 15 14 13 12 11 10 9 8 nparity7 wordaddr7 7 6 543210 wordaddr7 bitaddr7
405 6438fCatarmC21-jun-10 at91sam9g45 28.7 registers for 1 ecc per 256 bytes for a page of 512/2048/4 096 bytes, 8-bit word 28.7.1 ecc parity register 0 register name : ecc_pr0 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr0: corrupted bit address in the page between the first byte and the 255th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr0: corrupted word address in the page between the first by te and the 255th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity0: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity0 15 14 13 12 11 10 9 8 nparity0 0 wordaddr0 7 6 543210 wordaddr0 bitaddr0
406 6438fCatarmC21-jun-10 at91sam9g45 28.7.2 ecc parity register 1 register name : ecc_pr1 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area ? bitaddr1: corrupted bit address in the pa ge between the 256th and the 511th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr1: corrupted word address in the pa ge between the 256th and the 511th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity1: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity1 15 14 13 12 11 10 9 8 nparity1 0 wordaddr1 7 6 543210 wordaddr1 bitaddr1
407 6438fCatarmC21-jun-10 at91sam9g45 28.7.3 ecc parity register 2 register name : ecc_pr2 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr2: corrupted bit address in the pa ge between the 512th and the 767th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr2: corrupted word address in the pa ge between the 512th and the 767th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity2: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity2 15 14 13 12 11 10 9 8 nparity2 0 wordadd2 7 6 543210 wordaddr2 bitaddr2
408 6438fCatarmC21-jun-10 at91sam9g45 28.7.4 ecc parity register 3 register name : ecc_pr3 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr3: corrupted bit address in the page between the 768th and the 1023rd bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr3: corrupted word address in the pa ge between the 768th and the 1023rd bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless ? nparity3: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity3 15 14 13 12 11 10 9 8 nparity3 0 wordaddr3 7 6 543210 wordaddr3 bitaddr3
409 6438fCatarmC21-jun-10 at91sam9g45 28.7.5 ecc parity register 4 register name : ecc_pr4 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area ? bitaddr4: corrupted bit addre ss in the page between the 1024th and th e 1279th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr4: corrupted word address in the pa ge between the 1024th and the 1279th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity4 parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity4 15 14 13 12 11 10 9 8 nparity4 0 wordaddr4 7 6 543210 wordaddr4 bitaddr4
410 6438fCatarmC21-jun-10 at91sam9g45 28.7.6 ecc parity register 5 register name : ecc_pr5 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr5: corrupted bit address in the page between the 1280th and the 1535th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr5: corrupted word address in the page between the 1280th and the 1535th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity5: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity5 15 14 13 12 11 10 9 8 nparity5 0 wordaddr5 7 6 543210 wordaddr5 bitaddr5
411 6438fCatarmC21-jun-10 at91sam9g45 28.7.7 ecc parity register 6 register name : ecc_pr6 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr6: corrupted bit addre ss in the page between the 1536th and the1791st bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr6: corrupted word address in the pa ge between the 1536th and the1791st bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity6: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity6 15 14 13 12 11 10 9 8 nparity6 0 wordaddr6 7 6 543210 wordaddr6 bitaddr6
412 6438fCatarmC21-jun-10 at91sam9g45 28.7.8 ecc parity register 7 register name : ecc_pr7 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr7: corrupted bit address in the page between the 1792nd an d the 2047th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr7: corrupted word address in the pa ge between the 1792nd and the 2047th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity7: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity7 15 14 13 12 11 10 9 8 nparity7 0 wordaddr7 7 6 543210 wordaddr7 bitaddr7
413 6438fCatarmC21-jun-10 at91sam9g45 28.7.9 ecc parity register 8 register name : ecc_pr8 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr8: corrupted bit address in the pa ge between the 2048th and the2303rd bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr8: corrupted word address in the page between the 2048th and the 2303rd bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity8: parity n. 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity8 15 14 13 12 11 10 9 8 nparity8 0 wordaddr8 7 6 543210 wordaddr8 bitaddr8
414 6438fCatarmC21-jun-10 at91sam9g45 28.7.10 ecc parity register 9 register name : ecc_pr9 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area ? bitaddr9: corrupted bit addre ss in the page between the 2304th and th e 2559th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr9: corrupted word address in the pa ge between the 2304th and the 2559th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless ? nparity9 parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity9 15 14 13 12 11 10 9 8 nparity9 0 wordaddr9 7 6 543210 wordaddr9 bitaddr9
415 6438fCatarmC21-jun-10 at91sam9g45 28.7.11 ecc parity register 10 register name : ecc_pr10 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr10: corrupted bit address in the page between the 2560th and the2815th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr10: corrupted word address in the page between the 2560th and the 2815th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity10: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity10 15 14 13 12 11 10 9 8 nparity10 0 wordaddr10 7 6 543210 wordaddr10 bitaddr10
416 6438fCatarmC21-jun-10 at91sam9g45 28.7.12 ecc parity register 11 register name : ecc_pr11 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr11: corrupted bit address in the page between the 2816th and the 3071st bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr11: corrupted word address in the page between the 2816th and the 3071st bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity11: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity11 15 14 13 12 11 10 9 8 nparity11 0 wordaddr11 7 6 543210 wordaddr11 bitaddr11
417 6438fCatarmC21-jun-10 at91sam9g45 28.7.13 ecc parity register 12 register name : ecc_pr12 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr12; corrupted bit address in the page between the 3072nd and the 3327th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr12: corrupted word address in the page between the 3072nd and the 3327th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity12: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity12 15 14 13 12 11 10 9 8 nparity12 0 wordaddr12 7 6 543210 wordaddr12 bitaddr12
418 6438fCatarmC21-jun-10 at91sam9g45 28.7.14 ecc parity register 13 register name : ecc_pr13 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr13: corrupted bit address in the page between the 3328th and the 3583rd bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr13: corrupted word address in the page between the 3328th and the 3583rd bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity13: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity13 15 14 13 12 11 10 9 8 nparity13 0 wordaddr13 7 6 543210 wordaddr13 bitaddr13
419 6438fCatarmC21-jun-10 at91sam9g45 28.7.15 ecc parity register 14 register name : ecc_pr14 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area. ? bitaddr14: corrupted bit address in the page between the 3584th and the 3839th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr14: corrupted word address in the page between the 3584th and the 3839th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity14: parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity14 15 14 13 12 11 10 9 8 nparity14 0 wordaddr14 7 6 543210 wordaddr14 bitaddr14
420 6438fCatarmC21-jun-10 at91sam9g45 28.7.16 ecc parity register 15 register name : ecc_pr15 access type : read-only once the entire main area of a page is written with data, the register content must be stored at any free location of the spare area ? bitaddr15: corrupted bit address in the page between the 3840th and the 4095th bytes during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr15: corrupted word address in the page between the 3840th and the 4095th bytes during a page read, this value contains the word address (8-bit word) where an error occurred, if a single error was detected. if multiple errors were de tected, this value is meaningless. ? nparity15 parity n 31 30 29 28 27 26 25 24 C C CCCCCC 23 22 21 20 19 18 17 16 0nparity15 15 14 13 12 11 10 9 8 nparity15 0 wordaddr15 7 6 543210 wordaddr15 bitaddr15
421 6438fCatarmC21-jun-10 at91sam9g45 29. serial peripheral interface (spi) 29.1 description the serial peripheral interface (spi) circuit is a synchronous serial data link that provides com- munication with external devices in master or slave mode. it also enables communication between processors if an external processor is connected to the system. the serial peripheral interface is essentially a shift register that serially transmits data bits to other spis. during a data transfer, one spi syste m acts as the master' which controls the data flow, while the other devices act as slaves'' whic h have data shifted into and out by the master. different cpus can take turn being masters (multiple master protocol opposite to single master protocol where one cpu is always the master while all of the others are always slaves) and one master may simultaneously shift da ta into multiple slaves. howeve r, only one slave may drive its output to write data back to the master at any given time. a slave device is selected when the master asse rts its nss signal. if multiple slave devices exist, the master generates a separate slav e select signal for each slave (npcs). the spi system consists of two data lines and two control lines: ? master out slave in (mosi): this data line supplies the output data from the master shifted into the input(s) of the slave(s). ? master in slave out (miso): this data line supplies the output data from a slave to the input of the master. there may be no more than one slave transmitting data during any particular transfer. ? serial clock (spck): this control line is driven by the master and regulates the flow of the data bits. the master may transmit data at a variety of baud rates; the spck line cycles once for each bit that is transmitted. ? slave select (nss): this control line allows slaves to be turned on and off by hardware. 29.2 embedded characteristics ? supports communication with serial external devices C four chip selects with external decoder support allow communication with up to 15 peripherals C serial memories, such as dataflash and 3-wire eeproms C serial peripherals, such as adcs, dacs, lcd controllers, can controllers and sensors C external co-processors ? master or slave serial peripheral bus interface C 8- to 16-bit programmable data length per chip select C programmable phase and polarity per chip select C programmable transfer delays between consecutive transfers and between clock and data per chip select C programmable delay between consecutive transfers C selectable mode fault detection ? very fast transfers supported C transfers with baud rates up to mck C the chip select line may be left active to speed up transfers on the same device
422 6438fCatarmC21-jun-10 at91sam9g45 29.3 block diagram figure 29-1. block diagram figure 29-2. block diagram s pi interf a ce interr u pt control pio pdc pmc mck s pi interr u pt s pck mi s o mo s i npc s 0/n ss npc s 1 npc s 2 npc s3 apb spi interface interrupt control pio peripher a l bridge dma ch. ahb m a trix pmc mck spi interrupt spck miso mosi npcs0/nss npcs1 npcs2 npcs3 apb
423 6438fCatarmC21-jun-10 at91sam9g45 29.4 application block diagram figure 29-3. application block diagram: single master/multiple slave implementation spi master spck miso mosi npcs0 npcs1 npcs2 spck miso mosi nss slave 0 spck miso mosi nss slave 1 spck miso mosi nss slave 2 nc npcs3
424 6438fCatarmC21-jun-10 at91sam9g45 29.5 signal description 29.6 product dependencies 29.6.1 i/o lines the pins used for interfacing the compliant ex ternal devices may be multiplexed with pio lines. the programmer must first program the pio controllers to assign the spi pins to their peripheral functions. 29.6.2 power management the spi may be clocked through the power management controller (pmc), thus the program- mer must first configure the pmc to enable the spi clock. table 29-1. signal description pin name pin description type master slave miso master in slave out input output mosi master out slave in output input spck serial clock output input npcs1-npcs3 peripheral chip selects output unused npcs0/nss peripheral chip select/slave select output input table 29-2. i/o lines instance signal i/o line peripheral spi0 spi0_miso pb0 a spi0 spi0_mosi pb1 a spi0 spi0_npcs0 pb3 a spi0 spi0_npcs1 pb18 b spi0 spi0_npcs1 pd24 a spi0 spi0_npcs2 pb19 b spi0 spi0_npcs2 pd25 a spi0 spi0_npcs3 pd27 b spi0 spi0_spck pb2 a spi1 spi1_miso pb14 a spi1 spi1_mosi pb15 a spi1 spi1_npcs0 pb17 a spi1 spi1_npcs1 pd28 b spi1 spi1_npcs2 pd18 a spi1 spi1_npcs3 pd19 a spi1 spi1_spck pb16 a
425 6438fCatarmC21-jun-10 at91sam9g45 29.6.3 interrupt the spi interface has an interrupt line connected to the advanced interrupt controller (aic).handling the spi interrupt requires programming the aic before configuring the spi. 29.6.4 peripheral dma controller (pdma) direct me mory access controller (dmac) the spi interface can be used in conjunction with the pdma dmac in order to reduce processor overhead. for a full description of the pdma dmac, refer to the corresponding section in the full datasheet. 29.7 functional description 29.7.1 modes of operation the spi operates in master mode or in slave mode. operation in master mode is programmed by writing at 1 the mstr bit in the mode register. the pins npcs0 to npcs3 are all configured as outputs, the spck pin is driven, the miso line is wired on the receiver input and the mosi line driven as an output by the transmitter. if the mstr bit is written at 0, the spi operates in slave mode. the miso line is driven by the transmitter output, the mosi line is wired on the re ceiver input, the spck pin is driven by the transmitter to synchronize the receiver. the npcs0 pin becomes an input, and is used as a slave select signal (nss). the pins npcs1 to npcs3 are not driven and can be used for other purposes. the data transfers are identically programmable for both modes of operations. the baud rate generator is activated only in master mode. 29.7.2 data transfer four combinations of polarity and phase are available for data transfers. the clock polarity is programmed with the cpol bit in the chip select register. the clock phase is programmed with the ncpha bit. these two parameters determine th e edges of the clock signal on which data is driven and sampled. each of the two parameters has two possible states, resulting in four possi- ble combinations that are incompatible with one another. thus, a master/slave pair must use the same parameter pair values to communicate. if multiple slaves are used and fixed in different configurations, the master must reconfigure itself each time it needs to communicate with a dif- ferent slave. table 29-3. peripheral ids instance id spi0 14 spi1 15
426 6438fCatarmC21-jun-10 at91sam9g45 table 29-4 shows the four modes and corresponding parameter settings. figure 29-4 and figure 29-5 show examples of data transfers. figure 29-4. spi transfer format (ncpha = 1, 8 bits per transfer) table 29-4. spi bus protocol mode spi mode cpol ncpha shift spck edge capt ure spck edge spck inactive level 0 0 1 falling rising low 1 0 0 rising falling low 2 1 1 rising falling high 3 1 0 falling rising high 6 * spck (cpol = 0) spck (cpol = 1) mosi (from master) miso (from slave) nss (to slave) spck cycle (for reference) msb msb lsb lsb 6 6 5 5 4 4 3 3 2 2 1 1 * not defined, but normally msb of previous character received. 1 2345 78 6
427 6438fCatarmC21-jun-10 at91sam9g45 figure 29-5. spi transfer format (ncpha = 0, 8 bits per transfer) 29.7.3 master mode operations when configured in master mode, the spi operates on the clock generated by the internal pro- grammable baud rate generator. it fully controls the data transfers to and from the slave(s) connected to the spi bus. the spi drives the chip select line to the slave and the serial clock signal (spck). the spi features two holding registers, the transmit data register and the receive data regis- ter, and a single shift register. the holding registers maintain the data flow at a constant rate. after enabling the spi, a data transfer begins when the processor writes to the spi_tdr (trans- mit data register). the written data is immediat ely transferred in the shift register and transfer on the spi bus starts. while the data in the shift register is shifted on the mosi line, the miso line is sampled and shifted in the shift register. receiving data cannot occur without transmit- ting data. if receiving mode is not needed, for example when communicating with a slave receiver only (such as an lcd), the receive status flags in the status register can be discarded. before writing the tdr, the pcs field in the spi_mr register must be set in order to select a slave. after enabling the spi, a data transfer begins when the processor writes to the spi_tdr (trans- mit data register). the written data is immediat ely transferred in the shift register and transfer on the spi bus starts. while the data in the shift register is shifted on the mosi line, the miso line is sampled and shifted in the shift register. transmission cannot occur without reception. before writing the tdr, the pcs field must be set in order to select a slave. if new data is written in spi_tdr during the transfer, it stays in it until the current transfer is completed. then, the received data is transferred from the shift register to spi_rdr, the data in spi_tdr is loaded in the shift register and a new transfer starts. * spck (cpol = 0) spck (cpol = 1) 1 2345 7 mosi (from master) miso (from slave) nss (to slave) spck cycle (for reference) 8 msb msb lsb lsb 6 6 5 5 4 4 3 3 1 1 * not defined but normally lsb of previous character transmitted. 2 2 6
428 6438fCatarmC21-jun-10 at91sam9g45 the transfer of a data written in spi_tdr in t he shift register is indicated by the tdre bit (transmit data register empty) in the status register (spi_sr). when new data is written in spi_tdr, this bit is cleared. the tdre bit is used to trigger the transmit pdc channel. the end of transfer is indicated by the txempty flag in the spi_sr register. if a transfer delay (dlybct) is greater than 0 for the last transfer, txempty is set after the completion of said delay. the master clock (mck) can be switched off at this time. the transfer of received data from the shift register in spi_rdr is indicated by the rdrf bit (receive data register full) in the status register (spi_sr). when the received data is read, the rdrf bit is cleared. if the spi_rdr (receive data register) has not been read before new data is received, the overrun error bit (ovres) in spi_sr is set. as long as this flag is set, data is loaded in spi_rdr. the user has to read the status register to clear the ovres bit. figure 29-6 , shows a block diagram of the spi when operating in master mode. figure 29-7 on page 430 shows a flow chart describing how transfers are handled.
429 6438fCatarmC21-jun-10 at91sam9g45 29.7.3.1 master mode block diagram figure 29-6. master mode block diagram shift register spck mosi lsb msb miso spi_rdr rd spi clock tdre spi_tdr td rdrf ovres spi_csr0..3 cpol ncpha bits mck baud rate generator spi_csr0..3 scbr npcs3 npcs0 npcs2 npcs1 npcs0 0 1 ps spi_mr pcs spi_tdr pcs modf current peripheral spi_rdr pcs spi_csr0..3 csaat pcsdec modfdis mstr
430 6438fCatarmC21-jun-10 at91sam9g45 29.7.3.2 master mode flow diagram figure 29-7. master mode flow diagram spi enable csaat ? ps ? 1 0 0 1 1 npcs = spi_tdr(pcs) npcs = spi_mr(pcs) delay dlybs serializer = spi_tdr(td) tdre = 1 data transfer spi_rdr(rd) = serializer rdrf = 1 tdre ? npcs = 0xf delay dlybcs fixed peripheral variable peripheral delay dlybct 0 1 csaat ? 0 tdre ? 1 0 ps ? 0 1 spi_tdr(pcs) = npcs ? no yes spi_mr(pcs) = npcs ? no npcs = 0xf delay dlybcs npcs = spi_tdr(pcs) npcs = 0xf delay dlybcs npcs = spi_mr(pcs), spi_tdr(pcs) fixed peripheral variable peripheral - npcs defines the current chip select - csaat, dlybs, dlybct refer to the fields of the chip select register corresponding to the current chip select - when npcs is 0xf, csaat is 0.
431 6438fCatarmC21-jun-10 at91sam9g45 figure 29-8 shows transmit data register empty (t dre), receive data register (rdrf) and transmission register empty (txempty) status flags behavior within the spi_sr (status reg- ister) during an 8-bit data transfer in fixed mode and no peripheral data controller involved. figure 29-8. status register flags behavior figure 29-9 shows transmission register empty (txempty), end of rx buffer (endrx), end of tx buffer (endtx), rx buffer full (rxbuff) and tx buffer empty (txbufe) status flags behavior within the spi_sr (status register) during an 8-bit data transfer in fixed mode with the peripheral data controller involved. the pdc is programmed to transfer and receive three data. the next pointer and counter are not used. the rdrf and tdre are not shown because these flags are managed by the pdc when using the pdc. 6 spck mosi (from master) miso (from slave) npcs0 msb msb lsb lsb 6 6 5 5 4 4 3 3 2 2 1 1 1 2345 78 6 rdrf tdre txempty write in spi_tdr rdr read shift register empty
432 6438fCatarmC21-jun-10 at91sam9g45 figure 29-9. pdc status register flags behavior 29.7.3.3 clock generation the spi baud rate clock is generated by dividing the master clock (mck), by a value between 1 and 255. this allows a maximum operating baud rate at up to master clock and a minimum operating baud rate of mck divided by 255. programming the scbr field at 0 is forbidden. tr iggering a transfer while scbr is at 0 can lead to unpredictable results. at reset, scbr is 0 and the user has to program it at a valid value before performing the first transfer. the divisor can be defined independently for each chip select, as it has to be programmed in the scbr field of the chip select registers. this allows the spi to automatically adapt the baud rate for each interfaced peripheral without reprogramming. 29.7.3.4 transfer delays figure 29-10 shows a chip select transfer change and consecutive transfers on the same chip select. three delays can be programmed to modify the transfer waveforms: ? the delay between chip selects, programmable only once for all the ch ip selects by writing the dlybcs field in the mode register. allows insertion of a delay between release of one chip select and before assertion of a new one. ? the delay before spck, independently programmable for each chip select by writing the field dlybs. allows the start of spck to be delayed after the chip select has been asserted. ? the delay between consecutive transfers, independently programmable for each chip select by writing the dlybct field. allows insertion of a delay between two transfers occurring on the same chip select msb lsb 654321 spck mosi (from master) npcs0 msb lsb 654321 12 3 endtx txempty msb lsb 654321 msb lsb 654321 miso (from slave) msb lsb 654321 msb lsb 654321 endrx txbufe rxbuff
433 6438fCatarmC21-jun-10 at91sam9g45 these delays allow the spi to be adapted to the interfaced peripherals and their speed and bus release time. figure 29-10. programmable delays 29.7.3.5 peripheral selection the serial peripherals are selected through the assertion of the npcs0 to npcs3 signals. by default, all the npcs signals are high before and after each transfer. ? fixed peripheral select: spi exchanges data with only one peripheral fixed peripheral select is activated by writing the ps bit to zero in spi_mr (mode register). in this case, the current peripheral is defined by the pcs field in spi_mr and the pcs field in the spi_tdr has no effect. ? variable peripheral select: data can be exchanged with more than one peripheral without having to reprogram the npcs field in the spi_mr register. variable peripheral select is activated by se tting ps bit to one. the pcs field in spi_tdr is used to select the current peripheral. this means that the peripheral selection can be defined for each new data. the value to write in the spi_tdr register as the following format. [xxxxxxx(7-bit) + lastxfer(1-bit) (1) + xxxx(4-bit) + pcs (4-bit) + data (8 to 16-bit)] with pcs equals to the chip select to assert as defined in section 29.8.4 (spi transmit data register) and lastxfer bit at 0 or 1 depending on csaat bit. csaat, lastxfer and csnaat bit are dis- cussed in the peripher al deselection in section 29.7.3.11 . note: 1. optional. 29.7.3.6 spi peripheral dma controller (pdc) in both fixed and variable mode the peripheral dma controller (pdc) can be used to reduce processor overhead. the fixed peripheral selection allows buffer transfers with a single peripheral. using the pdc is an optimal means, as the size of the data transfer between the memory and the spi is either 8 bits or 16 bits. however, changing the peripheral selection requires the mode register to be reprogrammed. the variable peripheral selection allows buffer transfers with multiple peripherals without repro- gramming the mode register. data written in spi_tdr is 32 bits wide and defines the real data to be transmitted and the peripheral it is desti ned to. using the pdc in this mode requires 32-bit wide buffers, with the data in the lsbs and the pcs and lastxfer fields in the msbs, how- dlybcs dlybs dlybct dlybct chip select 1 chip select 2 spck
434 6438fCatarmC21-jun-10 at91sam9g45 ever the spi still controls the number of bits (8 to16) to be transferre d through miso and mosi lines with the chip select configuration registers. this is not the optimal means in term of mem- ory size for the buffers, but it provides a very effective means to exchange data with several peripherals without any intervention of the processor. 29.7.3.7 transfer size depending on the data size to transmit, from 8 to 16 bits, the pdc manages automatically the type of pointer's size it has to point to. th e pdc will perform the followin g transfer size depend- ing on the mode and number of bits per data. fixed mode: ?8-bit data: byte transfer, pdc pointer address = address + 1 byte, pdc counter = counter - 1 ? 8-bit to 16-bit data: 2 bytes transfer. n-bit data transfer with dont care data (msb) filled with 0s, pdc pointer address = address + 2 bytes, pdc counter = counter - 1 variable mode: in variable mode, pdc pointer address = address +4 bytes and pdc counter = counter - 1 for 8 to 16-bit transfer size. when using the pdc, the tdre and rdrf flags are handled by the pdc, thus the users application does not have to check those bits. only end of rx buffer (endrx), end of tx buffer (endtx), buffer fu ll (rxbuff), tx buffer empty (txbufe) are significant. for further details about the periph eral dma controller and user interface, refer to the pdc section of the product datasheet. 29.7.3.8 spi direct access memory controller (dmac) in both fixed and variable mode the direct memo ry access controller (dmac) can be used to reduce processor overhead. the fixed peripheral selection allows buffer tran sfers with a single perip heral. using the dmac is an optimal means, as the size of the data tr ansfer between the memory and the spi is either 8 bits or 16 bits. however, changing the peripheral selection requires the mode register to be reprogrammed. the variable peripheral selection allows buffer transfers with multiple peripherals without repro- gramming the mode register. data written in spi_tdr is 32 bits wide and defines the real data to be transmitted and the peripheral it is destined to. using the dmac in this mode requires 32- bit wide buffers, with the data in the lsbs and the pcs and lastxfer fields in the msbs, how- ever the spi still controls the number of bits (8 to16) to be transferre d through miso and mosi lines with the chip select configuration registers. this is not the optimal means in term of mem- ory size for the buffers, but it provides a very effective means to exchange data with several peripherals without any intervention of the processor.
435 6438fCatarmC21-jun-10 at91sam9g45 29.7.3.9 peripheral chip select decoding the user can program the spi to operate with up to 15 peripherals by decoding the four chip select lines, npcs0 to npcs3 with 1 of up to 16 decoder/demultiplexer. this can be enabled by writing the pcsdec bit at 1 in the mode register (spi_mr). when operating without decoding, the spi makes sure that in any case only one chip select line is activated, i.e., one npcs line driven low at a time. if two bits are defined low in a pcs field, only the lowest numbered ch ip select is driven low. when operating with decoding, the spi directly outputs the value defined by the pcs field on npcs lines of either the mode register or the transmit data register (depending on ps). as the spi sets a default value of 0xf on the chip select lines (i.e. all chip select lines at 1) when not processing any transfer, only 15 peripherals can be decoded. the spi has only four chip select registers, not 15. as a result, when decoding is activated, each chip select defines the characteristics of up to four peripherals. as an example, spi_crs0 defines the characteristics of the externally decoded peripherals 0 to 3, corresponding to the pcs values 0x0 to 0x3. thus, the user has to make sure to connect compatible peripherals on the decoded chip select lines 0 to 3, 4 to 7, 8 to 11 and 12 to 14. figure 29-11 below shows such an implementation. if the csaat bit is used, with or without the pdc, the mode fault detection for npcs0 line must be disabled. this is not needed for all other chip select lines since mode fault detection is only on npcs0. if the csaat bit is used, with or without the dmac, the mode fault detection for npcs0 line must be disabled. this is not needed for all other chip select lines since mode fault detection is only on npcs0. figure 29-11. chip select decoding applicati on block diagram: single master/multiple slave implementation spi master spck miso mosi npcs0 npcs1 npcs2 spck 1-of-n decoder/demultiplexer miso mosi nss slave 0 spck miso mosi nss slave 1 spck miso mosi nss slave 14 npcs3
436 6438fCatarmC21-jun-10 at91sam9g45 29.7.3.10 peripheral dese lection without pdcdmac during a transfer of more than one data on a chip select without the pdc dmac , the spi_tdr is loaded by the processor, the flag tdre rises as soon as the content of the spi_tdr is trans- ferred into the internal shift register. when this flag is detected high, the spi_tdr can be reloaded. if this reload by the processor occurs before the end of the current transfer and if the next transfer is performed on the same chip select as the current transfer, the chip select is not de-asserted between the two transfers. but depending on the application software handling the spi status register flags (by interrupt or polli ng method) or servicing other interrupts or other tasks, the processor may not reload the spi_tdr in time to keep the chip select active (low). a null delay between consecutive transfer (dlybc t) value in the spi_csr register, will give even less time for the processor to reload t he spi_tdr. with some spi slave peripherals, requiring the chip select line to remain active (low) during a full set of transfers might lead to communication errors. to facilitate interfacing with such devices, the chip select register [csr0...csr3] can be pro- grammed with the csaat bit (chip select active af ter transfer) at 1. this allows the chip select lines to remain in their current state (low = active) until transfer to another chip select is required. even if the spi_tdr is not reloa ded the chip select will remain active. to have the chip select line to raise at the end of the transfer the last transfer bit (lastxfer) in the spi_mr register must be set at 1 before writing the last data to transmit into the spi_tdr. 29.7.3.11 peripheral deselection with pdc when the peripheral dma controller is used, the chip select line will remain low during the whole transfer since the tdre flag is managed by the pdc itself. the reloading of the spi_tdr by the pdc is done as soon as tdre flag is set to one. in this case t he use of csaat bit might not be needed. however, it may happen that when other pdc channels connected to other peripherals are in use as well, the spi pdc might be delayed by another (pdc with a higher pri- ority on the bus). having pdc buffers in slower memories like flash memory or sdram compared to fast internal sram, may lengthen t he reload time of the spi_tdr by the pdc as well. this means that the spi_t dr might not be reloaded in time to keep the chip select line low. in this case the chip select line may toggle between data transfer and according to some spi slave devices, the communi cation might get lost. the use of the csaat bit might be needed. 29.7.3.12 peripheral de selection with dmac when the direct memory access controller is used, the chip select line will remain low during the whole transfer since the tdre flag is managed by the dmac itself. the reloading of the spi_tdr by the dmac is done as soon as tdre flag is set to one. in this case the use of csaat bit might not be needed. however, it may happen that when other dmac channels con- nected to other peripherals are in use as well, the spi dmac might be delayed by another (dmac with a higher priority on the bus). having dmac buffers in slower memories like flash memory or sdram compared to fast internal sram, may lengthen the reload time of the spi_tdr by the dmac as well. this means that the spi_tdr might not be reloaded in time to keep the chip select line low. in this case the chip select line may toggle between data transfer and according to some spi slave devices, the communication might get lost. the use of the csaat bit might be needed. figure 29-12 shows different peri pheral deselction cases and the effect of the csaat bit.
437 6438fCatarmC21-jun-10 at91sam9g45 figure 29-12. peripheral deselection 29.7.3.13 mode fault detection a mode fault is detected when the spi is programmed in master mode and a low level is driven by an external master on the npcs0/nss signal. in this case, multi-master configuration, npcs0, mosi, miso and spck pins must be configured in open drain (through the pio control- ler). when a mode fault is detected, the modf bit in the spi_sr is set until the spi_sr is read and the spi is automatically disabled until re-enabled by writing the spien bit in the spi_cr (control register) at 1. by default, the mode fault detection circuitr y is enabled. the user can disable mode fault detection by setting the modfdis bit in the spi mode register (spi_mr). 29.7.4 spi slave mode when operating in slave mode, the spi processes data bits on the clock provided on the spi clock pin (spck). the spi waits for nss to go active before receiving the serial clock from an external master. when nss falls, the clock is validated on the serializer, which processes the number of bits defined by the bits field of the chip select register 0 (spi_csr0). these bits are processed following a phase and a polarity defined respectively by the ncpha and cpol bits of the spi_csr0. note that bits, cpol and ncpha of the other chip select registers have no effect when the spi is programmed in slave mode. a npcs[0..3] write spi_tdr tdre npcs[0..3] write spi_tdr tdre npcs[0..3] write spi_tdr tdre dlybcs pcs = a dlybcs dlybct a pcs = b b dlybcs pcs = a dlybcs dlybct a pcs = b b dlybcs dlybct pcs=a a dlybcs dlybct a pcs = a a a dlybct aa csaat = 0 dlybct aa csaat = 1 a
438 6438fCatarmC21-jun-10 at91sam9g45 the bits are shifted out on the miso line and sampled on the mosi line. (for more information on bits field, see also, the (note:) below the register table; section 29.8.9 spi chip select register on page 450 .) when all the bits are processed, the received data is transferred in the receive data register and the rdrf bit rises. if the spi_rdr (receive data register) has no t been read be fore new data is received, the overrun error bit (ovres) in spi_sr is set. as long as this flag is set, data is loaded in spi_rdr. the user has to read the status register to clear the ovres bit. when a transfer starts, the data shifted out is the data present in the shift register. if no data has been written in the transmit data register (spi_tdr), the la st data received is transferred. if no data has been received since the last reset, all bits are transmitted low, as the shift regis- ter resets at 0. when a first data is written in sp i_tdr, it is transferred immediat ely in the shift register and the tdre bit rises. if new data is wr itten, it remains in spi_tdr unt il a transfer occurs, i.e. nss falls and there is a valid clock on the spck pin. w hen the transfer occurs, the last data written in spi_tdr is transferred in the shift register and the tdre bit rises. this enables frequent updates of critical variables with single transfers. then, a new data is loaded in the shift register from the transmit data register. in case no character is ready to be transmitted, i.e. no character has been written in spi_tdr since the last load from spi_tdr to the shift register, the shift register is not modified and the last received character is retransmitted. figure 29-13 shows a block diagram of the spi when operating in slave mode. figure 29-13. slave mode functional bloc diagram shift register spck spiens lsb msb nss mosi spi_rdr rd spi clock tdre spi_tdr td rdrf ovres spi_csr0 cpol ncpha bits spien spidis miso
439 6438fCatarmC21-jun-10 at91sam9g45 29.8 serial peripheral inte rface (spi) user interface table 29-5. register mapping offset register name access reset 0x00 control register spi_cr write-only --- 0x04 mode register spi_mr read-write 0x0 0x08 receive data register spi_rdr read-only 0x0 0x0c transmit data register spi_tdr write-only --- 0x10 status register spi_sr read-only 0x000000f0 0x14 interrupt enable register spi_ier write-only --- 0x18 interrupt disable register spi_idr write-only --- 0x1c interrupt mask register spi_imr read-only 0x0 0x20 - 0x2c reserved 0x30 chip select register 0 spi_csr0 read-write 0x0 0x34 chip select register 1 spi_csr1 read-write 0x0 0x38 chip select register 2 spi_csr2 read-write 0x0 0x3c chip select register 3 spi_csr3 read-write 0x0 0x004c - 0x00f8 reserved C C C 0x100 - 0x124 reserved for the pdc C C C
440 6438fCatarmC21-jun-10 at91sam9g45 29.8.1 spi control register name: spi_cr addresses: 0xfffa4000 (0), 0xfffa8000 (1) access: write-only ? spien: spi enable 0 = no effect. 1 = enables the spi to transfer and receive data. ? spidis: spi disable 0 = no effect. 1 = disables the spi. as soon as spidis is set, spi finishes its transfer. all pins are set in input mode and no data is received or transmitted. if a transfer is in progress, the transfer is finished before the spi is disabled. if both spien and spidis are equal to one when the control register is written, the spi is disabled. ? swrst: spi software reset 0 = no effect. 1 = reset the spi. a software-triggered hardware reset of the spi interface is performed. the spi is in slave mode after software reset. pdc channels are not affected by software reset. ? lastxfer: last transfer 0 = no effect. 1 = the current npcs will be deasserted afte r the character written in td has been transferred. when csaat is set, this allows to close the communication with the current serial peri pheral by raising the correspo nding npcs line as soon as td transfer has completed. 31 30 29 28 27 26 25 24 CCCCCCClastxfer 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 swrstCCCCCspidisspien
441 6438fCatarmC21-jun-10 at91sam9g45 29.8.2 spi mode register name: spi_mr addresses: 0xfffa4004 (0), 0xfffa8004 (1) access: read/write ? mstr: master/slave mode 0 = spi is in slave mode. 1 = spi is in master mode. ? ps: peripheral select 0 = fixed peripheral select. 1 = variable peripheral select. ? pcsdec: chip select decode 0 = the chip selects are directly connected to a peripheral device. 1 = the four chip select lines are connected to a 4- to 16-bit decoder. when pcsdec equals one, up to 15 chip select signals can be generated with the four lines using an external 4- to 16-bit decoder. the chip select registers define the characteristics of the 15 chip selects according to the following rules: spi_csr0 defines peripheral chip select signals 0 to 3. spi_csr1 defines peripheral chip select signals 4 to 7. spi_csr2 defines peripheral chip select signals 8 to 11. spi_csr3 defines peripheral chip select signals 12 to 14. ? modfdis: mode fault detection 0 = mode fault detection is enabled. 1 = mode fault detection is disabled. ? llb: local loopback enable 0 = local loopback path disabled. 1 = local loopback path enabled llb controls the local loopback on the data serializer for te sting in master mode only. (miso is internally connected on mosi.) 31 30 29 28 27 26 25 24 dlybcs 23 22 21 20 19 18 17 16 CCCC pcs 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 llb C C modfdis C pcsdec ps mstr
442 6438fCatarmC21-jun-10 at91sam9g45 ? pcs: peripheral chip select this field is only used if fixed peripheral select is active (ps = 0). if pcsdec = 0: pcs = xxx0 npcs[3:0] = 1110 pcs = xx01 npcs[3:0] = 1101 pcs = x011 npcs[3:0] = 1011 pcs = 0111 npcs[3:0] = 0111 pcs = 1111 forbidden (no peripheral is selected) (x = dont care) if pcsdec = 1: npcs[3:0] output signals = pcs. ? dlybcs: delay between chip selects this field defines the delay from npcs inactive to the ac tivation of another npcs. the dlybcs time guarantees non-over- lapping chip selects and solves bus contentions in case of peripherals having long data float times. if dlybcs is less than or eq ual to six, six mck periods will be inserted by default. otherwise, the following equat ion determines the delay: delay between chip selects dlybcs mck ---------------------- - =
443 6438fCatarmC21-jun-10 at91sam9g45 29.8.3 spi receive data register name: spi_rdr addresses: 0xfffa4008 (0), 0xfffa8008 (1) access: read-only ? rd: receive data data received by the spi interface is stored in this register right-justified. unused bits read zero. ? pcs: peripheral chip select in master mode only, these bits indicate the value on the npcs pins at the end of a transfer. otherwise, these bits read zero. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCC pcs 15 14 13 12 11 10 9 8 rd 76543210 rd
444 6438fCatarmC21-jun-10 at91sam9g45 29.8.4 spi transmit data register name: spi_tdr addresses: 0xfffa400c (0), 0xfffa800c (1) access: write-only ? td: transmit data data to be transmitted by the spi interface is stored in this register. information to be transmitted must be written to the transmit data register in a right-justified format. ? pcs: peripheral chip select this field is only used if variable peripheral select is active (ps = 1). if pcsdec = 0: pcs = xxx0 npcs[3:0] = 1110 pcs = xx01 npcs[3:0] = 1101 pcs = x011 npcs[3:0] = 1011 pcs = 0111 npcs[3:0] = 0111 pcs = 1111 forbidden (no peripheral is selected) (x = dont care) if pcsdec = 1: npcs[3:0] output signals = pcs ? lastxfer: last transfer 0 = no effect. 1 = the current npcs will be deasserted afte r the character written in td has been transferred. when csaat is set, this allows to close the communication with the current serial peri pheral by raising the correspo nding npcs line as soon as td transfer has completed. this field is only used if variable peripheral select is active (ps = 1). 31 30 29 28 27 26 25 24 CCCCCCClastxfer 23 22 21 20 19 18 17 16 CCCC pcs 15 14 13 12 11 10 9 8 td 76543210 td
445 6438fCatarmC21-jun-10 at91sam9g45 29.8.5 spi status register name: spi_sr addresses: 0xfffa4010 (0), 0xfffa8010 (1) access: read-only ? rdrf: receive data register full 0 = no data has been received since the last read of spi_rdr 1 = data has been received and the received data has been transferred from the serializer to spi_rdr since the last read of spi_rdr. ? tdre: transmit data register empty 0 = data has been written to spi_tdr and not yet transferred to the serializer. 1 = the last data written in the transmit data register has been transferred to the serializer. tdre equals zero when the spi is disabled or at reset. the spi enable command sets this bit to one. ? modf: mode fault error 0 = no mode fault has been detected since the last read of spi_sr. 1 = a mode fault occurred since the last read of the spi_sr. ? ovres: overrun error status 0 = no overrun has been detected since the last read of spi_sr. 1 = an overrun has occurred since the last read of spi_sr. an overrun occurs when spi_r dr is loaded at least twice from the serializer since the last read of the spi_rdr. ? endrx: end of rx buffer 0 = the receive counter register has not reached 0 since the last write in spi_rcr (1) or spi_rncr (1) . 1 = the receive counter register has reached 0 since the last write in spi_rcr (1) or spi_rncr (1) . ? endtx: end of tx buffer 0 = the transmit counter register has not reached 0 since the last write in spi_tcr (1) or spi_tncr (1) . 1 = the transmit counter register has reached 0 since the last write in spi_tcr (1) or spi_tncr (1) . ? rxbuff: rx buffer full 0 = spi_rcr (1) or spi_rncr (1) has a value other than 0. 1 = both spi_rcr (1) and spi_rncr (1) have a value of 0. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCspiens 15 14 13 12 11 10 9 8 CCCCCCtxemptynssr 76543210 CCCCovresmodftdre rdrf
446 6438fCatarmC21-jun-10 at91sam9g45 ? txbufe: tx buffer empty 0 = spi_tcr (1) or spi_tncr (1) has a value other than 0. 1 = both spi_tcr (1) and spi_tncr (1) have a value of 0. ? nssr: nss rising 0 = no rising edge detected on nss pin since last read. 1 = a rising edge occurred on nss pin since last read. ? txempty: transmission registers empty 0 = as soon as data is written in spi_tdr. 1 = spi_tdr and internal shifter are empty. if a transfer delay has been defined, txempty is set after the completion of such delay. ? spiens: spi enable status 0 = spi is disabled. 1 = spi is enabled. note: 1. spi_rcr, spi_rncr, spi_tcr, spi_tncr are physica lly located in the pdc.
447 6438fCatarmC21-jun-10 at91sam9g45 29.8.6 spi interrupt enable register name: spi_ier addresses: 0xfffa4014 (0), 0xfffa8014 (1) access: write-only 0 = no effect. 1 = enables the corresponding interrupt. ? rdrf: receive data register full interrupt enable ? tdre: spi transmit data regi ster empty interrupt enable ? modf: mode fault error interrupt enable ? ovres: overrun error interrupt enable ? endrx: end of receive buffer interrupt enable ? endtx: end of transmit buffer interrupt enable ? rxbuff: receive buffer full interrupt enable ? txbufe: transmit buffer empty interrupt enable ? nssr: nss rising interrupt enable ? txempty: transmission registers empty enable 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCtxemptynssr 76543210 CCCCovresmodftdre rdrf
448 6438fCatarmC21-jun-10 at91sam9g45 29.8.7 spi interrupt disable register name: spi_idr addresses: 0xfffa4018 (0), 0xfffa8018 (1) access: write-only 0 = no effect. 1 = disables the corresponding interrupt. ? rdrf: receive data register full interrupt disable ? tdre: spi transmit data register empty interrupt disable ? modf: mode fault error interrupt disable ? ovres: overrun error interrupt disable ? endrx: end of receive buffer interrupt disable ? endtx: end of transmit buffer interrupt disable ? rxbuff: receive buffer full interrupt disable ? txbufe: transmit buffer empty interrupt disable ? nssr: nss rising interrupt disable ? txempty: transmission registers empty disable 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCtxemptynssr 76543210 CCCCovresmodftdre rdrf
449 6438fCatarmC21-jun-10 at91sam9g45 29.8.8 spi interrupt mask register name: spi_imr addresses: 0xfffa401c (0), 0xfffa801c (1) access: read-only 0 = the corresponding interrupt is not enabled. 1 = the corresponding interrupt is enabled. ? rdrf: receive data register full interrupt mask ? tdre: spi transmit data register empty interrupt mask ? modf: mode fault error interrupt mask ? ovres: overrun error interrupt mask ? endrx: end of receive buffer interrupt mask ? endtx: end of transmit buffer interrupt mask ? rxbuff: receive buffer full interrupt mask ? txbufe: transmit buffer empty interrupt mask ? nssr: nss rising interrupt mask ? txempty: transmission registers empty mask 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCtxemptynssr 76543210 CCCCovresmodftdre rdrf
450 6438fCatarmC21-jun-10 at91sam9g45 29.8.9 spi chip select register name: spi_csr0... spi_csr3 addresses: 0xfffa4030 (0), 0xfffa8030 (1) access: read/write note: spi_csrx registers must be written even if the user wants to use the defaults. the bits field will not be updated with the trans- lated value unless the register is written. ? cpol: clock polarity 0 = the inactive state value of spck is logic level zero. 1 = the inactive state value of spck is logic level one. cpol is used to determine the inactive state value of the serial clock (spck). it is used with ncpha to produce the required clock/data relationship between master and slave devices. ? ncpha: clock phase 0 = data is changed on the leading edge of spck and captured on the following edge of spck. 1 = data is captured on the leading edge of spck and changed on the following edge of spck. ncpha determines which edge of spck causes data to change and which edge causes data to be captured. ncpha is used with cpol to produce the required clock/da ta relationship between master and slave devices. ? csaat: chip select active after transfer 0 = the peripheral chip select line rises as soon as the last transfer is achieved. 1 = the peripheral chip select does not rise after the last transfer is achieved. it remains active until a new transfer is requested on a different chip select. ? bits: bits per transfer (see the (note:) below the register table; section 29.8.9 spi chip select register on page 450 .) the bits field determines the number of data bits transferred. reserved values should not be used. 31 30 29 28 27 26 25 24 dlybct 23 22 21 20 19 18 17 16 dlybs 15 14 13 12 11 10 9 8 scbr 76543210 bits csaat C ncpha cpol bits bits per transfer 0000 8 0001 9 0010 10 0011 11 0100 12 0101 13 0110 14 0111 15
451 6438fCatarmC21-jun-10 at91sam9g45 ? scbr: serial clock baud rate in master mode, the spi interface uses a modulus counter to derive the spck baud rate from the master clock mck. the baud rate is selected by writing a value from 1 to 255 in the scbr field. the following equations determine the spck baud rate: programming the scbr field at 0 is forbidden. triggering a trans fer while scbr is at 0 can le ad to unpredictable results. at reset, scbr is 0 and the user has to program it at a valid value before performing the first transfer. ? dlybs: delay before spck this field defines the delay from npcs valid to the first valid spck transition. when dlybs equals zero, the npcs valid to spck transition is 1/2 the spck clock period. otherwise, the following equations determine the delay: ? dlybct: delay between consecutive transfers this field defines the delay between two consecutive transfers with the same perip heral without removing the chip select. the delay is always inserted after each transfer and before removing the chip select if needed. when dlybct equals zero, no delay between consecutive transf ers is inserted and the clock keeps its duty cycle over the character transfers. otherwise, the following equat ion determines the delay: 1000 16 1001 reserved 1010 reserved 1011 reserved 1100 reserved 1101 reserved 1110 reserved 1111 reserved bits bits per transfer spck baudrate mck scbr -------------- - = delay before spck dlybs mck ------------------ - = delay between cons ecutive transfers 32 dlybct mck ------------------------------------ =
452 6438fCatarmC21-jun-10 at91sam9g45
453 6438fCatarmC21-jun-10 at91sam9g45 30. parallel input/outp ut controller (pio) 30.1 description the parallel input/output controller (pio) manages up to 32 fully programmable input/output lines. each i/o line may be dedicated as a general-purpose i/o or be assigned to a function of an embedded peripheral. this assures effective optimization of the pins of a product. each i/o line is associated with a bit number in all of the 32-bit registers of the 32-bit wide user interface. each i/o line of the pio controller features: ? an input change interrupt enabling level change detection on any i/o line. ? a glitch filter providing rejection of pulses lower than one-half of clock cycle. ? multi-drive capability similar to an open drain i/o line. ? control of the the pull-up of the i/o line. ? input visibility and output control. the pio controller also features a synchronous output providing up to 32 bits of data output in a single write operation.
454 6438fCatarmC21-jun-10 at91sam9g45 30.2 block diagram figure 30-1. block diagram figure 30-2. application block diagram embedded peripheral embedded peripheral pio interrupt pio controller up to 32 pins pmc up to 32 peripheral ios up to 32 peripheral ios pio clock apb aic data, enable pin 31 pin 1 pin 0 data, enable on-chip peripherals pio controller on-chip peripheral drivers control & command driver keyboard driver keyboard driver general purpose i/os external devices
455 6438fCatarmC21-jun-10 at91sam9g45 30.3 product dependencies 30.3.1 pin multiplexing each pin is configurable, according to product definition as either a general-purpose i/o line only, or as an i/o line multiplexed with one or two peripheral i/os. as the multiplexing is hard- ware-defined and thus product-dependent, the hardware designer and programmer must carefully determine the configuration of the pio controllers required by their application. when an i/o line is general-purpose only, i.e. not multiplexed with any peripheral i/o, programming of the pio controller regarding the assignment to a peripheral has no effect and only the pio con- troller can control how the pin is driven by the product. 30.3.2 external interrupt lines the interrupt signals fiq and irq0 to irqn are most generally multiplexed through the pio controllers. however, it is not necessary to assign the i/o line to the interrupt function as the pio controller has no effect on inputs and the interrupt lines (fiq or irqs) are used only as inputs. 30.3.3 power management the power management controller controls the pio controller clock in order to save power. writing any of the registers of the user interface does not require the pio controller clock to be enabled. this means that the configuration of the i/o lines does not require the pio controller clock to be enabled. however, when the clock is disabled, not all of t he features of the pio controller are available. note that the input change interrupt and the read of the pin level require the clock to be validated. after a hardware reset, the pio clock is disabled by default. the user must configure the power management controller before any access to the input line information. 30.3.4 interrupt generation for interrupt handling, the pio controllers are considered as user peripherals. this means that the pio controller interrupt lines are connected among the interrupt sources 2 to 31. refer to the pio controller peripheral identifier in the produc t description to identify the interrupt sources dedicated to the pio controllers. the pio controller interrupt can be generated only if the pio controller clock is enabled.
456 6438fCatarmC21-jun-10 at91sam9g45 30.4 functional description the pio controller features up to 32 fully-programmable i/o lines. most of the control logic asso- ciated to each i/o is represented in figure 30-3 . in this description each signal shown represents but one of up to 32 possible indexes. figure 30-3. i/o line control logic 1 0 1 0 1 0 glitch filter peripheral b input peripheral a input 1 0 pio_ifdr[0] pio_ifsr[0] pio_ifer[0] edge detector pio_pdsr[0] pio_isr[0] pio_idr[0] pio_imr[0] pio_ier[0] pio interrupt (up to 32 possible inputs) pio_isr[31] pio_idr[31] pio_imr[31] pio_ier[31] pad 1 0 pio_pudr[0] pio_pusr[0] pio_puer[0] pio_mddr[0] pio_mdsr[0] pio_mder[0] pio_codr[0] pio_odsr[0] pio_sodr[0] pio_pdr[0] pio_psr[0] pio_per[0] 1 0 1 0 pio_bsr[0] pio_absr[0] pio_asr[0] peripheral b output enable peripheral a output enable peripheral b output peripheral a output pio_odr[0] pio_osr[0] pio_oer[0]
457 6438fCatarmC21-jun-10 at91sam9g45 30.4.1 pull-up resistor control each i/o line is designed with an embedded pull-up resistor. the pull-up resistor can be enabled or disabled by writing respectively pio_puer (pull-up enable register) and pio_pudr (pull- up disable resistor). writing in these registers re sults in setting or clearing the corresponding bit in pio_pusr (pull-up status register). readi ng a 1 in pio_pusr means the pull-up is dis- abled and reading a 0 means the pull-up is enabled. control of the pull-up resistor is possible regardless of the configuration of the i/o line. after reset, all of the pull-ups are enabled, i.e. pio_pusr resets at the value 0x0. 30.4.2 i/o line or peripheral function selection when a pin is multiplexed with one or two periph eral functions, the selection is controlled with the registers pio_per (pio enable register) and pio_pdr (pio disable register). the regis- ter pio_psr (pio status register) is the resu lt of the set and clear registers and indicates whether the pin is controlled by the corresponding peripheral or by the pio controller. a value of 0 indicates that the pin is controlled by the co rresponding on-chip peripheral selected in the pio_absr (ab select status regist er). a value of 1 indicates the pin is controlled by the pio controller. if a pin is used as a general purpose i/o line (not multiplexed with an on-chip peripheral), pio_per and pio_pdr have no effect and pio_psr returns 1 for the corresponding bit. after reset, most generally, the i/o lines are controlled by the pio controller, i.e. pio_psr resets at 1. however, in some events, it is important that pio lines are controlled by the periph- eral (as in the case of memory chip select lines that must be driven inactive after reset or for address lines that must be driven low for booting out of an external memory). thus, the reset value of pio_psr is defined at the product level, depending on the multiplexing of the device. 30.4.3 peripheral a or b selection the pio controller provides multiplexing of up to two peripheral functions on a single pin. the selection is performed by writing pio_asr (a select register) and pio_bsr (select b regis- ter). pio_absr (ab select status register) indicates which peripheral line is currently selected. for each pin, the corresponding bit at level 0 means peripheral a is selected whereas the corre- sponding bit at level 1 indicates that peripheral b is selected. note that multiplexing of peripheral lines a and b only affects the output line. the peripheral input lines are always connected to the pin input. after reset, pio_absr is 0, thus indicating that all th e pio lines are config ured on peripheral a. however, peripheral a generally does not drive the pin as the pio controller resets in i/o line mode. writing in pio_asr an d pio_bsr manages pio_absr regardless of th e configuration of the pin. however, assignment of a pin to a peripheral function requires a write in the corresponding peripheral selection register (pio_asr or pio_bsr) in addition to a write in pio_pdr. 30.4.4 output control when the i/0 line is assigned to a peripheral func tion, i.e. the corresponding bit in pio_psr is at 0, the drive of the i/o line is controlled by the peripheral. peripheral a or b, depending on the value in pio_absr, determines whet her the pin is driven or not. when the i/o line is controlled by the pio controller, the pin can be configured to be driven. this is done by writing pio_oer (output enable register) and pio_odr (output disable register).
458 6438fCatarmC21-jun-10 at91sam9g45 the results of these write operations are detected in pio_osr (output status register). when a bit in this register is at 0, the corresponding i/o line is used as an input only. when the bit is at 1, the corresponding i/o line is driven by the pio controller. the level driven on an i/o line can be determined by writing in pio_sodr (set output data register) and pio_codr (cle ar output data register). these write operations respectively set and clear pio_odsr (output data status register ), which represents the data driven on the i/o lines. writing in pio_oer and pio_odr manage s pio_osr whether the pin is configured to be controlled by the pio controller or assigned to a peripheral function. this enables configura- tion of the i/o line prior to setting it to be managed by the pio controller. similarly, writing in pio_sodr and pio_codr effects pio_odsr. this is important as it defines the first level driven on the i/o line. 30.4.5 synchronous data output controlling all paralle l busses using several pios requires two successive write operations in the pio_sodr and pio_codr registers. this may lead to unexpected transient values. the pio controller offers a direct control of pio outputs by single write access to pio_odsr (output data status register). only bits unmasked by pio_owsr (output write status register) are written. the mask bits in the pio_owsr are se t by writing to pio_ower (output write enable register) and cleared by writing to pio_owdr (output write disable register). after reset, the synchronous data output is disabled on all the i/o lines as pio_owsr resets at 0x0. 30.4.6 multi drive control (open drain) each i/o can be independently programmed in open drain by using the multi drive feature. this feature permits several drivers to be connected on the i/o line which is driven low only by each device. an external pull-up resistor (or enabling of the internal one) is generally required to guar- antee a high level on the line. the multi drive feature is controlled by pio_mder (multi-driver enable register) and pio_mddr (multi-driver disable register). the multi drive can be selected whether the i/o line is controlled by the pio controller or assigned to a peripheral function. pio_mdsr (multi-driver status register) indicates the pins that are configured to support external drivers. after reset, the multi drive feature is disabled on all pins, i.e. pio_mdsr resets at value 0x0. 30.4.7 output line timings figure 30-4 shows how the outputs are driven either by writing pio_sodr or pio_codr, or by directly writing pio_odsr. this last case is va lid only if the corresponding bit in pio_owsr is set. figure 30-4 also shows when the feedback in pio_pdsr is available.
459 6438fCatarmC21-jun-10 at91sam9g45 figure 30-4. output line timings 30.4.8 inputs the level on each i/o line can be read through pio_pdsr (pin data status register). this reg- ister indicates the level of the i/o lines regardless of their configuration, whether uniquely as an input or driven by the pio controller or driven by a peripheral. reading the i/o line levels requires the clock of the pio controller to be enabled, otherwise pio_pdsr reads the levels present on the i/o line at the time the clock was disabled. 30.4.9 input glitch filtering optional input glitch filters are independently programmable on each i/o line. when the glitch fil- ter is enabled, a glitch with a duration of less than 1/2 master clock (mck) cycle is automatically rejected, while a pulse with a duration of 1 mast er clock cycle or more is accepted. for pulse durations between 1/2 master clock cycle and 1 master clock cycle the pulse may or may not be taken into account, depending on the precise timing of its occurrence. thus for a pulse to be visible it must exceed 1 master clock cycle, whereas for a glitch to be reliably filtered out, its duration must not exceed 1/2 master clock cycle. the filter introduces one master clock cycle latency if the pin level change occurs before a rising edge. however, this latency does not appear if the pin level chan ge occurs before a falling ed ge. this is illustrated in figure 30-5 . the glitch filters are controlled by the regist er set; pio_ifer (input filter enable register), pio_ifdr (input filter disable register) and pio_ifsr (input filter status register). writing pio_ifer and pio_ifdr respectively sets and clears bits in pio_ifsr. this last register enables the glitch filt er on the i/o lines. when the glitch filter is enabled, it does not modify the behavior of the inputs on the peripherals. it acts only on the value read in pio_pdsr and on the input change interrupt detection. the glitch filters require that the pio controller clock is enabled. 2 cycles apb access 2 cycles apb access mck write pio_sodr write pio_odsr at 1 pio_odsr pio_pdsr write pio_codr write pio_odsr at 0
460 6438fCatarmC21-jun-10 at91sam9g45 figure 30-5. input glitch filter timing 30.4.10 input change interrupt the pio controller can be programmed to generate an interrupt when it detects an input change on an i/o line. the input change interrupt is cont rolled by writing pio_ier (interrupt enable register) and pio_idr (interrupt disable register), which respectively enable and disable the input change interrupt by setting and clearing the corresponding bit in pio_imr (interrupt mask register). as input change detection is possible only by comparing two successive samplings of the input of the i/o line, the pio controller clock must be enabled. the input change interrupt is available, regardless of the configuration of the i/o line, i.e. configured as an input only, con- trolled by the pio controller or assigned to a peripheral function. when an input change is detected on an i/o line, the corresponding bit in pio_isr (interrupt status register) is set. if the corresponding bit in pio_imr is set, the pio controller interrupt line is asserted. the interrupt signals of the thirty-two channels are ored-wired together to gen- erate a single interrupt signal to the advanced interrupt controller. when the software reads pio_isr, all the interrupts are automatically cleared. this signifies that all the interrupts that are pending when pio_isr is read must be handled. figure 30-6. input change interrupt timings 30.4.11 write protected registers to prevent any single software error that may corrupt the pio behavior, the registers listed below can be write-protected by setting the wpen bit in the pio write protect mode register (pio_wpmr). mck pin level pio_pdsr if pio_ifsr = 0 pio_pdsr if pio_ifsr = 1 1 cycle 1 cycle 1 cycle up to 1.5 cycles 2 cycles up to 2.5 cycles up to 2 cycles 1 cycle 1 cycle mck pin level read pio_isr apb access pio_isr apb access
461 6438fCatarmC21-jun-10 at91sam9g45 if a write access in a write-prot ected register is detected, then the wpvs flag in the pio write protect status register (pio_wpsr) is set and the field wpvsrc indicates in which register the write access has been attempted. the wpvs flag is automatically reset after reading the pio write protect status register (pio_wpsr). list of the write-protected registers: ? pio enable register on page 466 ? pio disable register on page 466 ? pio output enable register on page 467 ? pio output disable register on page 468 ? pio input filter enable register on page 469 ? pio input filter disable register on page 469 ? pio set output data register on page 470 ? pio clear output data register on page 471 ? pio multi-driver enable register on page 474 ? pio multi-driver disable register on page 475 ? pio pull up disable register on page 476 ? pio pull up enable register on page 476 ? pio peripheral a select register on page 477 ? pio peripheral b select register on page 478 ? pio output write enable register on page 479 ? pio output write disable register on page 479 30.4.12 programmable i/o delays the pio interface consists of a series of signals dr iven by peripherals or directly by sofware. the simultaneous switching outputs on these busses may lead to a peak of current in the internal and external power supply lines. in order to reduce the peak of current in such cases, additional propagation delays can be adjusted independently for pad buffers by means of configuration registers, pio_delay. for each i/o, the additional programmable delays range from 0 to 4 ns (worst case pvt). the delay can differ between ios supporting this feature. the delay can be modified according to programming for each i/o. the minimum additional delay that can be programmed on a pad supporting this feature is 1/16 of the maximum programmable delay. only pads pc[12], pc[7:2], pa[30:23] and pa[9:2] can be configured. when programming 0x0 in fields, no delay is added (reset value) and the propagation delay of the pad buffers is the inherent delay of the pad buffer. when programming 0xf in field, the prop- agation delay of the corresponding pad is maximal.
462 6438fCatarmC21-jun-10 at91sam9g45 figure 30-7. programmable i/o delays 30.5 i/o lines programming example the programing example as shown in table 30-1 below is used to define the following configuration. ? 4-bit output port on i/o lines 0 to 3, (should be written in a single write operation), open-drain, with pull-up resistor ? four output signals on i/o lines 4 to 7 (to drive leds for example), driven high and low, no pull-up resistor ? four input signals on i/o lines 8 to 11 (to read push-button states for example), with pull-up resistors, glitch filters and input change interrupts ? four input signals on i/o line 12 to 15 to read an external device status (polled, thus no input change interrupt), no pull-up resistor, no glitch filter ? i/o lines 16 to 19 assigned to peripheral a functions with pull-up resistor ? i/o lines 20 to 23 assigned to peripheral b functions, no pull-up resistor ? i/o line 24 to 27 assigned to peripheral a with input change interrupt and pull-up resistor delay1 programmable delay line pio paout[0] pain[0] delay2 programmable delay line delayx programmable delay line paout[1] pain[1] paout[2] pain[2] table 30-1. programming example register value to be written pio_per 0x0000 ffff pio_pdr 0x0fff 0000 pio_oer 0x0000 00ff pio_odr 0x0fff ff00 pio_ifer 0x0000 0f00 pio_ifdr 0x0fff f0ff pio_sodr 0x0000 0000 pio_codr 0x0fff ffff
463 6438fCatarmC21-jun-10 at91sam9g45 pio_ier 0x0f00 0f00 pio_idr 0x00ff f0ff pio_mder 0x0000 000f pio_mddr 0x0fff fff0 pio_pudr 0x00f0 00f0 pio_puer 0x0f0f ff0f pio_asr 0x0f0f 0000 pio_bsr 0x00f0 0000 pio_ower 0x0000 000f pio_owdr 0x0fff fff0 table 30-1. programming example (continued)
464 6438fCatarmC21-jun-10 at91sam9g45 30.6 parallel input/output cont roller (pio) user interface each i/o line controlled by the pio controller is associated with a bit in each of the pio control- ler user interface registers. each register is 32 bits wide. if a parallel i/o line is not defined, writing to the corresponding bits has no effect. undefined bits read zero. if the i/o line is not mul- tiplexed with any peripheral, the i/o line is controlled by the pio controller and pio_psr returns 1 systematically. table 30-2. register mapping offset register name access reset 0x0000 pio enable register pio_per write-only C 0x0004 pio disable register pio_pdr write-only C 0x0008 pio status register pio_psr read-only (1) 0x000c reserved 0x0010 output enable register pio_oer write-only C 0x0014 output disable register pio_odr write-only C 0x0018 output status regist er pio_osr read-only 0x0000 0000 0x001c reserved 0x0020 glitch input filter enab le register pio_ifer write-only C 0x0024 glitch input filter disab le register pio_ifdr write-only C 0x0028 glitch input filter status register pio_ifsr read-only 0x0000 0000 0x002c reserved 0x0030 set output data register pio_sodr write-only C 0x0034 clear output data register pio_codr write-only 0x0038 output data status register pio_odsr read-only or (2) read/write C 0x003c pin data status register pio_pdsr read-only (3) 0x0040 interrupt enable register pio_ier write-only C 0x0044 interrupt disable register pio_idr write-only C 0x0048 interrupt mask register pio_imr read-only 0x00000000 0x004c interrupt status register (4) pio_isr read-only 0x00000000 0x0050 multi-driver enable register pio_mder write-only C 0x0054 multi-driver disable register pio_mddr write-only C 0x0058 multi-driver status re gister pio_mdsr read-only 0x00000000 0x005c reserved 0x0060 pull-up disable register pio_pudr write-only C 0x0064 pull-up enable register pio_puer write-only C 0x0068 pad pull-up status regi ster pio_pusr read-only 0x00000000 0x006c reserved
465 6438fCatarmC21-jun-10 at91sam9g45 notes: 1. reset value of pio_psr depends on the product implementation. 2. pio_odsr is read-only or read/write depending on pio_owsr i/o lines. 3. reset value of pio_pdsr depends on the level of the i/o line s. reading the i/o line levels requires the clock of the pio controller to be enabled, ot herwise pio_pdsr reads the levels present on the i/o line at the time the clock was disabled. 4. pio_isr is reset at 0x0. however, the first read of the register may read a different value as input changes may have occurred. 5. only this set of registers clears the stat us by writing 1 in the first register and sets the status by writing 1 in the secon d register. 0x0070 peripheral a select register (5) pio_asr write-only C 0x0074 peripheral b select register (5) pio_bsr write-only C 0x0078 ab status register (5) pio_absr read-only 0x00000000 0x007c-0x009c reserved 0x00a0 output write enab le pio_ower write-only C 0x00a4 output write disab le pio_owdr write-only C 0x00a8 output write status re gister pio_owsr read-only 0x00000000 0x00ac reserved 0x00c0 i/o delay register pio_delay0r read/write 0x00000000 0x00c4 i/o delay register pio_delay1r read/write 0x00000000 0x00c8 i/o delay register pio_delay2r read/write 0x00000000 0x00cc i/o delay register pio_delay3r read/write 0x00000000 0x00c4-00e0 reserved 0x00e4 write protect mode register pio_wpmr read-write 0x00000000 0x00e8 write protect status r egister pio_wpsr read-only 0x00000000 0x00f0-0x00f8 reserved table 30-2. register mapping (continued) offset register name access reset
466 6438fCatarmC21-jun-10 at91sam9g45 30.6.1 pio enable register name: pio_per addresses: 0xfffff200 (pioa), 0xfffff400 (piob), 0xfffff600 (pioc), 0xfffff800 (piod), 0xfffffa00 (pioe) access type: write-only ? p0-p31: pio enable 0 = no effect. 1 = enables the pio to control the corresponding pin (disables peripheral control of the pin). 30.6.2 pio disable register name: pio_pdr addresses: 0xfffff204 (pioa), 0xfffff404 (piob), 0xfffff604 (pioc), 0xfffff804 (piod), 0xfffffa04 (pioe) access type: write-only ? p0-p31: pio disable 0 = no effect. 1 = disables the pio from controllin g the corresponding pin (enables peripheral contro l of the pin). 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
467 6438fCatarmC21-jun-10 at91sam9g45 30.6.3 pio status register name: pio_psr addresses: 0xfffff208 (pioa), 0xfffff408 (piob), 0xfffff608 (pioc), 0xfffff808 (piod), 0xfffffa08 (pioe) access type: read-only ? p0-p31: pio status 0 = pio is inactive on the corresponding i/o line (peripheral is active). 1 = pio is active on the corresponding i/o line (peripheral is inactive). 30.6.4 pio output enable register name: pio_oer addresses: 0xfffff210 (pioa), 0xfffff410 (piob), 0xfffff610 (pioc), 0xfffff810 (piod), 0xfffffa10 (pioe) access type: write-only ? p0-p31: output enable 0 = no effect. 1 = enables the output on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
468 6438fCatarmC21-jun-10 at91sam9g45 30.6.5 pio output disable register name: pio_odr addresses: 0xfffff214 (pioa), 0xfffff414 (piob), 0xfffff614 (pioc), 0xfffff814 (piod), 0xfffffa14 (pioe) access type: write-only ? p0-p31: output disable 0 = no effect. 1 = disables the output on the i/o line. 30.6.6 pio output status register name: pio_osr addresses: 0xfffff218 (pioa), 0xfffff418 (piob), 0xfffff618 (pioc), 0xfffff818 (piod), 0xfffffa18 (pioe) access type: read-only ? p0-p31: output status 0 = the i/o line is a pure input. 1 = the i/o line is enabled in output. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
469 6438fCatarmC21-jun-10 at91sam9g45 30.6.7 pio input filter enable register name: pio_ifer addresses: 0xfffff220 (pioa), 0xfffff420 (piob), 0xfffff620 (pioc), 0xfffff820 (piod), 0xfffffa20 (pioe) access type: write-only ? p0-p31: input filter enable 0 = no effect. 1 = enables the input glitch filter on the i/o line. 30.6.8 pio input filter disable register name: pio_ifdr addresses: 0xfffff224 (pioa), 0xfffff424 (piob), 0xfffff624 (pioc), 0xfffff824 (piod), 0xfffffa24 (pioe) access type: write-only ? p0-p31: input filter disable 0 = no effect. 1 = disables the input glitch filter on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
470 6438fCatarmC21-jun-10 at91sam9g45 30.6.9 pio input filter status register name: pio_ifsr addresses: 0xfffff228 (pioa), 0xfffff428 (piob), 0xfffff628 (pioc), 0xfffff828 (piod), 0xfffffa28 (pioe) access type: read-only ? p0-p31: input filer status 0 = the input glitch filter is disabled on the i/o line. 1 = the input glitch filter is enabled on the i/o line. 30.6.10 pio set output data register name: pio_sodr addresses: 0xfffff230 (pioa), 0xfffff430 (piob), 0xfffff630 (pioc), 0xfffff830 (piod), 0xfffffa30 (pioe) access type: write-only ? p0-p31: set output data 0 = no effect. 1 = sets the data to be driven on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
471 6438fCatarmC21-jun-10 at91sam9g45 30.6.11 pio clear output data register name: pio_codr addresses: 0xfffff234 (pioa), 0xfffff434 (piob), 0xfffff634 (pioc), 0xfffff834 (piod), 0xfffffa34 (pioe) access type: write-only ? p0-p31: clear output data 0 = no effect. 1 = clears the data to be driven on the i/o line. 30.6.12 pio output data status register name: pio_odsr addresses: 0xfffff238 (pioa), 0xfffff438 (piob), 0xfffff638 (pioc), 0xfffff838 (piod), 0xfffffa38 (pioe) access type: read-only or read/write ? p0-p31: output data status 0 = the data to be driven on the i/o line is 0. 1 = the data to be driven on the i/o line is 1. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
472 6438fCatarmC21-jun-10 at91sam9g45 30.6.13 pio pin data status register name: pio_pdsr addresses: 0xfffff23c (pioa), 0xfffff43c (piob), 0xfffff63c (pioc), 0xfffff83c (piod), 0xfffffa3c (pioe) access type: read-only ? p0-p31: output data status 0 = the i/o line is at level 0. 1 = the i/o line is at level 1. 30.6.14 pio interrupt enable register name: pio_ier addresses: 0xfffff240 (pioa), 0xfffff440 (piob), 0xfffff640 (pioc), 0xfffff840 (piod), 0xfffffa40 (pioe) access type: write-only ? p0-p31: input change interrupt enable 0 = no effect. 1 = enables the input change interrupt on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
473 6438fCatarmC21-jun-10 at91sam9g45 30.6.15 pio interrupt disable register name: pio_idr addresses: 0xfffff244 (pioa), 0xfffff444 (piob), 0xfffff644 (pioc), 0xfffff844 (piod), 0xfffffa44 (pioe) access type: write-only ? p0-p31: input change interrupt disable 0 = no effect. 1 = disables the input change interrupt on the i/o line. 30.6.16 pio interrupt mask register name: pio_imr addresses: 0xfffff248 (pioa), 0xfffff448 (piob), 0xfffff648 (pioc), 0xfffff848 (piod), 0xfffffa48 (pioe) access type: read-only ? p0-p31: input change interrupt mask 0 = input change interrupt is disabled on the i/o line. 1 = input change interrupt is enabled on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
474 6438fCatarmC21-jun-10 at91sam9g45 30.6.17 pio interrupt status register name: pio_isr addresses: 0xfffff24c (pioa), 0xfffff44c (piob), 0xfffff64c (pioc), 0xfffff84c (piod), 0xfffffa4c (pioe) access type: read-only ? p0-p31: input change interrupt status 0 = no input change has been detected on the i/o line since pio_isr was last read or since reset. 1 = at least one input change has been detected on the i/o line since pio_isr was last read or since reset. 30.6.18 pio multi-driver enable register name: pio_mder addresses: 0xfffff250 (pioa), 0xfffff450 (piob), 0xfffff650 (pioc), 0xfffff850 (piod), 0xfffffa50 (pioe) access type: write-only ? p0-p31: multi drive enable. 0 = no effect. 1 = enables multi drive on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
475 6438fCatarmC21-jun-10 at91sam9g45 30.6.19 pio multi-driver disable register name: pio_mddr addresses: 0xfffff254 (pioa), 0xfffff454 (piob), 0xfffff654 (pioc), 0xfffff854 (piod), 0xfffffa54 (pioe) access type: write-only ? p0-p31: multi drive disable. 0 = no effect. 1 = disables multi drive on the i/o line. 30.6.20 pio multi-driver status register name: pio_mdsr addresses: 0xfffff258 (pioa), 0xfffff458 (piob), 0xfffff658 (pioc), 0xfffff858 (piod), 0xfffffa58 (pioe) access type: read-only ? p0-p31: multi drive status. 0 = the multi drive is disabled on the i/o line. the pin is driven at high and low level. 1 = the multi drive is enabled on the i/o lin e. the pin is driven at low level only. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
476 6438fCatarmC21-jun-10 at91sam9g45 30.6.21 pio pull up disable register name: pio_pudr addresses: 0xfffff260 (pioa), 0xfffff460 (piob), 0xfffff660 (pioc), 0xfffff860 (piod), 0xfffffa60 (pioe) access type: write-only ? p0-p31: pull up disable. 0 = no effect. 1 = disables the pull up resistor on the i/o line. 30.6.22 pio pull up enable register name: pio_puer addresses: 0xfffff264 (pioa), 0xfffff464 (piob), 0xfffff664 (pioc), 0xfffff864 (piod), 0xfffffa64 (pioe) access type: write-only ? p0-p31: pull up enable. 0 = no effect. 1 = enables the pull up resistor on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
477 6438fCatarmC21-jun-10 at91sam9g45 30.6.23 pio pull up status register name: pio_pusr addresses: 0xfffff268 (pioa), 0xfffff468 (piob), 0xfffff668 (pioc), 0xfffff868 (piod), 0xfffffa68 (pioe) access type: read-only ? p0-p31: pull up status. 0 = pull up resistor is enabled on the i/o line. 1 = pull up resistor is disabled on the i/o line. 30.6.24 pio peripheral a select register name: pio_asr addresses: 0xfffff270 (pioa), 0xfffff470 (piob), 0xfffff670 (pioc), 0xfffff870 (piod), 0xfffffa70 (pioe) access type: write-only ? p0-p31: peripheral a select. 0 = no effect. 1 = assigns the i/o line to the peripheral a function. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
478 6438fCatarmC21-jun-10 at91sam9g45 30.6.25 pio peripheral b select register name: pio_bsr addresses: 0xfffff274 (pioa), 0xfffff474 (piob), 0xfffff674 (pioc), 0xfffff874 (piod), 0xfffffa74 (pioe) access type: write-only ? p0-p31: peripheral b select. 0 = no effect. 1 = assigns the i/o line to the peripheral b function. 30.6.26 pio peripheral a b status register name: pio_absr addresses: 0xfffff278 (pioa), 0xfffff478 (piob), 0xfffff678 (pioc), 0xfffff878 (piod), 0xfffffa78 (pioe) access type: read-only ? p0-p31: peripheral a b status. 0 = the i/o line is assigned to the peripheral a. 1 = the i/o line is assigned to the peripheral b. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
479 6438fCatarmC21-jun-10 at91sam9g45 30.6.27 pio output write enable register name: pio_ower addresses: 0xfffff2a0 (pioa), 0xfffff4a0 (piob), 0xfffff6a0 (pioc), 0xfffff8a0 (piod), 0xfffffaa0 (pioe) access type: write-only ? p0-p31: output write enable. 0 = no effect. 1 = enables writing pio_odsr for the i/o line. 30.6.28 pio output write disable register name: pio_owdr addresses: 0xfffff2a4 (pioa), 0xfffff4a4 (piob), 0xfffff6a4 (pioc), 0xfffff8a4 (piod), 0xfffffaa4 (pioe) access type: write-only ? p0-p31: output write disable. 0 = no effect. 1 = disables writing pio_odsr for the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
480 6438fCatarmC21-jun-10 at91sam9g45 30.6.29 pio output write status register name: pio_owsr addresses: 0xfffff2a8 (pioa), 0xfffff4a8 (piob), 0xfffff6a8 (pioc), 0xfffff8a8 (piod), 0xfffffaa8 (pioe) access type: read-only ? p0-p31: output write status. 0 = writing pio_odsr does not affect the i/o line. 1 = writing pio_odsr affects the i/o line. 30.6.30 pio i/o delay register register name: pio_delayxr [x=0..3] addresses: 0xfffff2c0 (pioa), 0xfffff4c0 (piob), 0xfffff6c0 (pioc), 0xfffff8c0 (piod), 0xfffffac0 (pioe) access type: read-write reset value: see figure 30-2 ? delay x: gives the number of elements in the delay line associated to pad x. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 31 30 29 28 27 26 25 24 delay7 delay6 23 22 21 20 19 18 17 16 delay5 delay4 15 14 13 12 11 10 9 8 delay3 delay2 76543210 delay1 delay0
481 6438fCatarmC21-jun-10 at91sam9g45 30.6.31 pio write protect mode register register name: pio_wpmr addresses: 0xfffff2e4 (pioa), 0xfffff4e4 (piob), 0xfffff6e4 (pioc), 0xfffff8e4 (piod), 0xfffffae4 (pioe) access type: read-write reset value: see table 30-2 ? wpen: write protect enable 0 = disables the write protect if wpkey co rresponds to 0x50494f (pio in ascii). 1 = enables the write protect if wpkey corresponds to 0x50494f (pio in ascii). protects the registers listed below: ? pio enable register on page 466 ? pio disable register on page 466 ? pio output enable register on page 467 ? pio output disable register on page 468 ? pio input filter enable register on page 469 ? pio input filter disable register on page 469 ? pio set output data register on page 470 ? pio clear output data register on page 471 ? pio multi-driver enable register on page 474 ? pio multi-driver disable register on page 475 ? pio pull up disable register on page 476 ? pio pull up enable register on page 476 ? pio peripheral a select register on page 477 ? pio peripheral b select register on page 478 ? pio output write enable register on page 479 ? pio output write disable register on page 479 ? wpkey: write protect key should be written at value 0x534d43 (smc in ascii). writing an y other value in this field aborts the write operation of the wpen bit. always reads as 0. 31 30 29 28 27 26 25 24 wpkey 23 22 21 20 19 18 17 16 wpkey 15 14 13 12 11 10 9 8 wpkey 76543210 wpen
482 6438fCatarmC21-jun-10 at91sam9g45 30.6.32 pio write protect status register register name: pio_wpsr addresses: 0xfffff2e8 (pioa), 0xfffff4e8 (piob), 0xfffff6e8 (pioc), 0xfffff8e8 (piod), 0xfffffae8 (pioe) access type: read-only reset value: see table 30-2 ? wpvs: write protect enable 0 = no write protect violation has occurred since the last read of the pio_wpsr register. 1 = a write protect violation occurred since the last read of the pio_wpsr register. if this violation is an unauthorized attempt to write a protected register, the associated violation is reported into field wpvsrc. ? wpvsrc: write protect violation source when wpvs is active, this field indicates the write-protected register (t hrough address offset or code) in which a write access has been attempted. note: reading pio_wpsr automatically clears all fields. 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 wpvsrc 15 14 13 12 11 10 9 8 wpvsrc 76543210 wpvs
483 6438fCatarmC21-jun-10 at91sam9g45 31. two-wire interface (twi) 31.1 description the atmel two-wire interface (twi) interconnects components on a unique two-wire bus, made up of one clock line and one data line with speeds of up to 400 kbits per second, based on a byte-oriented transfer format. it can be used with any atmel two-wire interface bus serial eeprom and i2c compatible device such as real time clock (rtc), dot matrix/graphic lcd controllers and temperature sensor, to name but a few. the twi is programmable as a master or a slave with sequential or single-byte acce ss. multiple master capability is supported. 20 arbitration of the bus is performed internally and puts the twi in slave mode automatically if the bus arbitration is lost. a configurable baud rate generator permits the output data rate to be adapted to a wide range of core clock frequencies. below, table 31-1 lists the compatibility level of the atme l two-wire interface in master mode and a full i 2 c compatible device. note: 1. start + b000000001 + ack + sr 31.2 embedded characteristics ? compatibility with standard two-wire serial memory ? one, two or three bytes for slave address ? sequential read/write operations ? supports either master or slave modes ? compatible with standard two-wire serial memories ? master, multi-master and slave mode operation ? bit rate: up to 400 kbits ? general call supported in slave mode ? connection to peripheral dma controller (p dc) channel capabilit ies optimizes data transfers in master mode only C one channel for the receiver, one channel for the transmitter C next buffer support table 31-1. atmel twi compatibility with i 2 c standard i 2 c standard atmel twi standard mode speed (100 khz) supported fast mode speed (400 khz) supported 7 or 10 bits slave addressing supported start byte (1) not supported repeated start (sr) condition supported ack and nack management supported slope control and input filtering (fast mode) not supported clock stretching supported multi master capability supported
484 6438fCatarmC21-jun-10 at91sam9g45 31.3 list of abbreviations 31.4 block diagram figure 31-1. block diagram table 31-2. abbreviations abbreviation description twi two-wire interface a acknowledge na non acknowledge pstop sstart sr repeated start sadr slave address adr any address except sadr r read wwrite apb bridge pmc mck two-wire interface pio aic twi interrupt twck twd
485 6438fCatarmC21-jun-10 at91sam9g45 31.5 application block diagram figure 31-2. application block diagram 31.5.1 i/o lines description 31.6 product dependencies 31.6.1 i/o lines both twd and twck are bidirectional lines, connect ed to a positive supply voltage via a current source or pull-up resistor (see figure 31-2 on page 485 ). when the bus is free, both lines are high. the output stages of devices connected to the bus must have an open-drain or open-col- lector to perform the wired-and function. twd and twck pins may be multiplexed with pi o lines. to enable the twi, the programmer must perform the following step: ? program the pio controller to dedicate twd and twck as peripheral lines. the user must not program twd and twck as open-drain. it is already done by the hardware. table 31-3. i/o lines description pin name pin description type twd two-wire serial data input/output twck two-wire serial clock input/output host with twi interface twd twck atmel twi serial eeprom i2c rtc i2c lcd controller slave 1 slave 2 slave 3 vdd i2c temp. sensor slave 4 rp: pull up value as given by the i2c standard rp rp table 31-4. i/o lines instance signal i/o line peripheral twi0 twck0 pa21 a twi0 twd0 pa20 a twi1 twck1 pb11 a twi1 twd1 pb10 a
486 6438fCatarmC21-jun-10 at91sam9g45 31.6.2 power management ? enable the peripheral clock. the twi interface may be clocked through the power management controller (pmc), thus the programmer must first configure the pmc to enable the twi clock. 31.6.3 interrupt the twi interface has an interrupt line connected to the advanced interrupt controller (aic). in order to handle interrupts, the aic must be programmed before configuring the twi. 31.7 functional description 31.7.1 transfer format the data put on the twd line must be 8 bits long. data is transferred msb first; each byte must be followed by an acknowledgement. the number of bytes per transfer is unlimited (see figure 31-4 ). each transfer begins with a start condition and terminates with a stop condition (see figure 31-3 ). ? a high-to-low transition on the twd line while twck is high defines the start condition. ? a low-to-high transition on the twd line while twck is high defines a stop condition. figure 31-3. start and stop conditions figure 31-4. transfer format 31.7.2 modes of operation the twi has six modes of operations: ? master transmitter mode ? master receiver mode table 31-5. peripheral ids instance id twi0 12 twi1 13 twd twck start stop twd twck start address r/w ack data ack data ack stop
487 6438fCatarmC21-jun-10 at91sam9g45 ? multi-master transmitter mode ? multi-master receiver mode ? slave transmitter mode ? slave receiver mode these modes are described in the following chapters.
488 6438fCatarmC21-jun-10 at91sam9g45 31.8 master mode 31.8.1 definition the master is the device that starts a transfer, generates a clock and stops it. 31.8.2 application block diagram figure 31-5. master mode typical ap plication block diagram 31.8.3 programming master mode the following registers have to be programmed before entering master mode: 1. dadr (+ iadrsz + iadr if a 10 bit device is addressed): the device address is used to access slave devices in read or write mode. 2. ckdiv + chdiv + cldiv: clock waveform. 3. svdis: disable the slave mode. 4. msen: enable the master mode. 31.8.4 master transmitter mode after the master initiates a start condition when writing into the tran smit holding register, twi_thr, it sends a 7-bit slave address, configured in the master mode register (dadr in twi_mmr), to notify the slave device. the bit following the slave address indicates the transfer direction, 0 in this case (mread = 0 in twi_mmr). the twi transfers require the slave to acknowledge each received byte. during the acknowl- edge clock pulse (9th pulse), the master releases the data line (high), enabling the slave to pull it down in order to generate the acknowledge. t he master polls the data line during this clock pulse and sets the not acknowledge bit ( nack) in the status register if the slave does not acknowledge the byte. as with the other status bits, an interrupt can be generated if enabled in the interrupt enable register (twi_ier). if the slave acknowledges the byte, the data written in the twi_thr, is then shifted in the internal shifter and transferred. when an acknowledge is detected, the txrdy bit is set until a new write in the twi_thr. while no new data is writ ten in the twi_thr, the serial clock line is tied low. when new data is written in the twi_thr, the scl is released and the data is sent. to generate a stop event, the stop command must be performed by writing in the stop field of twi_cr. host with twi interface twd twck atmel twi serial eeprom i2c rtc i2c lcd controller slave 1 slave 2 slave 3 vdd i2c temp. sensor slave 4 rp: pull up value as given by the i2c standard rp rp
489 6438fCatarmC21-jun-10 at91sam9g45 after a master write transfer, the serial clock line is stretched (tied low) while no new data is written in the twi_thr or until a stop command is performed. see figure 31-6 , figure 31-7 , and figure 31-8 . figure 31-6. master write with one data byte figure 31-7. master write with mu ltiple data bytes txcomp txrdy write thr (data) stop command sent (write in twi_cr) twd a data a s dadr w p a data n a s dadr w data n+1 a p data n+2 a txcomp txrdy write thr (data n) write thr (data n+1) write thr (data n+2) last data sent stop command performed (by writing in the twi_cr) twd twck
490 6438fCatarmC21-jun-10 at91sam9g45 figure 31-8. master write with one byte internal address and multiple data bytes 31.8.5 master receiver mode the read sequence begins by setting the start bit. after the start condition has been sent, the master sends a 7-bit slave address to notify th e slave device. the bit following the slave address indicates the transfer direction, 1 in this ca se (mread = 1 in twi_mmr). during the acknowl- edge clock pulse (9th pulse), the master releases the data line (high), enabling the slave to pull it down in order to generate the acknowledge. t he master polls the data line during this clock pulse and sets the nack bit in the status register if the slave does not acknowledge the byte. if an acknowledge is received, the master is then ready to receive data from the slave. after data has been received, the master sends an acknowle dge condition to notify the slave that the data has been received except for the last data, after the stop condition. see figure 31-9 . when the rxrdy bit is set in the status register, a character has been received in the receive-holding reg- ister (twi_rhr). the rxrdy bit is reset when reading the twi_rhr. when a single data byte read is performed, with or without internal address (iadr ), the start and stop bits must be set at the same time. see figure 31-9 . when a multiple data byte read is performed, with or without internal address (iadr ), the stop bit must be set after the next-to- last data received. see figure 31-10 . for internal address usage see section 31.8.6 . figure 31-9. master read with one data byte a data n a s dadr w data n+1 a p data n+2 a txcomp txrdy write thr (data n) write thr (data n+1) write thr (data n+2) last data sent stop command performed (by writing in the twi_cr) twd iadr a twck a s dadr r data n p txcomp write start & stop bit rxrdy read rhr twd
491 6438fCatarmC21-jun-10 at91sam9g45 figure 31-10. master read with mu ltiple data bytes 31.8.6 internal address the twi interface can perform various transfe r formats: transfers with 7-bit slave address devices and 10-bit slave address devices. 31.8.6.1 7-bit slave addressing when addressing 7-bit slave devices, the internal address bytes are used to perform random address (read or write) accesses to reach one or more data bytes, within a memory page loca- tion in a serial memory, for example. when performing read operations with an internal address, the twi performs a write operation to set the internal address into the slave device, and then switch to master receiver mode. note that the second start condition (after sending the iadr) is sometimes called repeat ed start (sr) in i 2 c fully-compatible devices. see figure 31-12 . see figure 31-11 and figure 31-13 for master write operation with internal address. the three internal address bytes are configurable through the master mode register (twi_mmr). if the slave device supports only a 7-bit address, i.e. no internal address, iadrsz must be set to 0. in the figures below the following abbreviations are used: n a s dadr r data n a a data (n+1) a data (n+m) data (n+m)-1 p twd txcomp write start bit rxrdy write stop bit after next-to-last data read read rhr data n read rhr data (n+1) read rhr data (n+m)-1 read rhr data (n+m) ?s start ?sr repeated start ?p stop ?w write ?r read ?a acknowledge ?n not acknowledge ?dadr device address ?iadr internal address
492 6438fCatarmC21-jun-10 at91sam9g45 figure 31-11. master write with one, two or three bytes internal address and one data byte figure 31-12. master read with one, two or three bytes internal address and one data byte 31.8.6.2 10-bit slave addressing for a slave address higher than 7 bits, the user must configure the address size (iadrsz ) and set the other slave address bits in the internal address register (twi_iadr). the two remaining internal address bytes, iadr[15:8] and iadr[23:16] can be used the same as in 7-bit slave addressing. example: address a 10-bit device (10-bit device address is b1 b2 b3 b4 b5 b6 b7 b8 b9 b10) 1. program iadrsz = 1, 2. program dadr with 1 1 1 1 0 b1 b2 (b1 is the msb of the 10-bit address, b2, etc.) 3. program twi_iadr with b3 b4 b5 b6 b7 b8 b9 b10 (b10 is the lsb of the 10-bit address) figure 31-13 below shows a byte write to an atmel at24lc512 eeprom. this demonstrates the use of internal addresses to access the device. figure 31-13. internal address usage s dadr w a iadr(23:16) a iadr(15:8) a iadr(7:0) a data a p s dadr w a iadr(15:8) a iadr(7:0) a p data a a iadr(7:0) a p data a s dadr w twd three bytes internal address two bytes internal address one byte internal address twd twd s dadr w a iadr(23:16) a iadr(15:8) a iadr(7:0) a s dadr w a iadr(15:8) a iadr(7:0) a a iadr(7:0) a s dadr w data n p sr dadr r a sr dadr r a data n p sr dadr ra data np twd twd twd three bytes internal address two bytes internal address one byte internal address s t a r t m s b device address 0 l s b r / w a c k m s b w r i t e a c k a c k l s b a c k first word address second word address data s t o p
493 6438fCatarmC21-jun-10 at91sam9g45 31.8.7 smbus quick command (master mode only) the twi interface can perform a quick command: 1. configure the master mode (dadr, ckdiv, etc.). 2. write the mread bit in the twi_mmr register at the value of the one-bit command to be sent. 3. start the transfer by setting the quick bit in the twi_cr. figure 31-14. smbus quick command 31.8.8 read-write flowcharts the following flowcharts shown in figure 31-16 on page 495 , figure 31-17 on page 496 , figure 31-18 on page 497 , figure 31-19 on page 498 and figure 31-20 on page 499 give examples for read and write operations. a polling or interrupt method can be used to check the status bits. the interrupt method requires that the interrupt enable register (twi_ier) be configured first. txcomp txrdy write quick command in twi_cr twd a s dadr r/w p
494 6438fCatarmC21-jun-10 at91sam9g45 figure 31-15. twi write operation with single data byte without internal address set twi clock (cldiv, chdiv, ckdiv) in twi_cwgr (needed only once) set the control register: - master enable twi_cr = msen + svdis set the master mode register: - device slave address (dadr) - transfer direction bit write ==> bit mread = 0 load transmit register twi_thr = data to send read status register txrdy = 1? read status register txcomp = 1? transfer finished ye s ye s begin no no write stop command twi_cr = stop
495 6438fCatarmC21-jun-10 at91sam9g45 figure 31-16. twi write operation with single data byte and internal address begin set twi clock (cldiv, chdiv, ckdiv) in twi_cwgr (needed only once) set the control register: - master enable twi_cr = msen + svdis set the master mode register: - device slave address (dadr) - internal address size (iadrsz) - transfer direction bit write ==> bit mread = 0 load transmit register twi_thr = data to send read status register txrdy = 1? read status register txcomp = 1? transfer finished set the internal address twi_iadr = address yes yes no no write stop command twi_cr = stop
496 6438fCatarmC21-jun-10 at91sam9g45 figure 31-17. twi write operation with multiple data bytes with or without internal address set the control register: - master enable twi_cr = msen + svdis set the master mode register: - device slave address - internal address size (if iadr used) - transfer direction bit write ==> bit mread = 0 internal address size = 0? load transmit register twi_thr = data to send read status register txrdy = 1? data to send? read status register txcomp = 1? end begin set the internal address twi_iadr = address ye s twi_thr = data to send ye s ye s ye s no no no write stop command twi_cr = stop set twi clock (cldiv, chdiv, ckdiv) in twi_cwgr (needed only once)
497 6438fCatarmC21-jun-10 at91sam9g45 figure 31-18. twi read operation with single data byte without internal address set the control register: - master enable twi_cr = msen + svdis set the master mode register: - device slave address - transfer direction bit read ==> bit mread = 1 start the transfer twi_cr = start | stop read status register rxrdy = 1? read status register txcomp = 1? end begin ye s ye s set twi clock (cldiv, chdiv, ckdiv) in twi_cwgr (needed only once) read receive holding register no no
498 6438fCatarmC21-jun-10 at91sam9g45 figure 31-19. twi read operation with single data byte and internal address set the control register: - master enable twi_cr = msen + svdis set the master mode register: - device slave address - internal address size (iadrsz) - transfer direction bit read ==> bit mread = 1 read status register txcomp = 1? end begin ye s set twi clock (cldiv, chdiv, ckdiv) in twi_cwgr (needed only once) ye s set the internal address twi_iadr = address start the transfer twi_cr = start | stop read status register rxrdy = 1? read receive holding register no no
499 6438fCatarmC21-jun-10 at91sam9g45 figure 31-20. twi read operation with multiple data bytes with or without internal address internal address size = 0? start the transfer twi_cr = start stop the transfer twi_cr = stop read status register rxrdy = 1? last data to read but one? read status register txcomp = 1? end set the internal address twi_iadr = address ye s ye s ye s no ye s read receive holding register (twi_rhr) no set the control register: - master enable twi_cr = msen + svdis set the master mode register: - device slave address - internal address size (if iadr used) - transfer direction bit read ==> bit mread = 1 begin set twi clock (cldiv, chdiv, ckdiv) in twi_cwgr (needed only once) no read status register rxrdy = 1? ye s read receive holding register (twi_rhr) no
500 6438fCatarmC21-jun-10 at91sam9g45 31.9 multi-master mode 31.9.1 definition more than one master may handle the bus at the same time without data corruption by using arbitration. arbitration starts as soon as two or more masters place information on the bus at the same time, and stops (arbitration is lost) for the master that intends to send a logical one while the other master sends a logical zero. as soon as arbitration is lost by a master, it st ops sending data and listens to the bus in order to detect a stop. when the stop is detected, the master who has lost arbitration may put its data on the bus by respecting arbitration. arbitration is illustrated in figure 31-22 on page 501 . 31.9.2 different multi-master modes two multi-master modes may be distinguished: 1. twi is considered as a master only and will never be addressed. 2. twi may be either a master or a slave and may be addressed. note: in both multi-master modes arbitration is supported. 31.9.2.1 twi as master only in this mode, twi is considered as a master only (msen is always at one) and must be driven like a master with the arblst (arbitration lost) flag in addition. if arbitration is lost (arblst = 1), the programmer must reinitiate the data transfer. if the user starts a transfer (ex.: dadr + start + w + write in thr) and if the bus is busy, the twi automatically waits for a stop conditi on on the bus to initiate the transfer (see figure 31- 21 on page 501 ). note: the state of the bus (busy or free) is not indicated in the user interface. 31.9.2.2 twi as master or slave the automatic reversal from master to slave is not supported in case of a lost arbitration. then, in the case where twi may be either a master or a slave, the programmer must manage the pseudo multi-master mode described in the steps below. 1. program twi in slave mode (sadr + ms dis + sven) and perform slave access (if twi is addressed). 2. if twi has to be set in master mode, wait until txcomp flag is at 1. 3. program master mode (dadr + svdis + msen ) and start the transfer (ex: start + write in thr). 4. as soon as the master mode is enabled, twi scans the bus in order to detect if it is busy or free. when the bus is considered as free, twi initiates the transfer. 5. as soon as the transfer is initiated and until a stop condition is sent, the arbitration becomes relevant and the user must monitor the arblst flag. 6. if the arbitration is lost (arblst is set to 1), the user must program the twi in slave mode in the case where the master that won the arbitration wanted to access the twi. 7. if twi has to be set in slave mode, wait until txcomp flag is at 1 and then program the slave mode.
501 6438fCatarmC21-jun-10 at91sam9g45 note: in the case where the arbitration is lost and tw i is addressed, twi will not acknowledge even if it is programmed in slave mode as soon as arblst is set to 1. then, the master must repeat sadr. figure 31-21. programmer sends data while the bus is busy figure 31-22. arbitration cases the flowchart shown in figure 31-23 on page 502 gives an example of read and write operations in multi-master mode. twck twd data sent by a master stop sent by the master start sent by the twi data sent by the twi bus is busy bus is free a transfer is programmed (dadr + w + start + write thr) transfer is initiated twi data transfer transfer is kept bus is considered as free twck bus is busy bus is free a transfer is programmed (dadr + w + start + write thr) transfer is initiated twi data transfer transfer is kept bus is considered as free data from a master data from twi s 0 s 0 0 1 1 1 arblst s 0 s 0 0 1 1 1 twd s 0 0 1 1 1 1 1 arbitration is lost twi stops sending data p s 0 1 p 0 1 1 1 1 data from the master data from the twi arbitration is lost the master stops sending data transfer is stopped transfer is programmed again (dadr + w + start + write thr) twck twd
502 6438fCatarmC21-jun-10 at91sam9g45 figure 31-23. multi-master flowchart programm the slave mode: sadr + msdis + sven svacc = 1 ? txcomp = 1 ? gacc = 1 ? decoding of the programming sequence prog seq ok ? change sadr svread = 0 ? read status register rxrdy= 0 ? read twi_rhr txrdy= 1 ? eosacc = 1 ? write in twi_thr need to perform a master access ? program the master mode dadr + svdis + msen + clk + r / w read status register arblst = 1 ? mread = 1 ? txrdy= 0 ? write in twi_thr data to send ? rxrdy= 0 ? read twi_rhr data to read? read status register txcomp = 0 ? general call treatment ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s stop transfer twi_cr = stop no no no no no no no no no no no no no no no no start
503 6438fCatarmC21-jun-10 at91sam9g45 31.10 slave mode 31.10.1 definition the slave mode is defined as a mode where the device receives the clock and the address from another device called the master. in this mode, the device never initiates and never completes the transmission (start, repeated_start and stop conditions are always provided by the master). 31.10.2 application block diagram figure 31-24. slave mode typical application block diagram 31.10.3 programming slave mode the following fields must be programmed before entering slave mode: 1. sadr (twi_smr): the slave device address is used in order to be accessed by mas- ter devices in read or write mode. 2. msdis (twi_cr): disable the master mode. 3. sven (twi_cr): enable the slave mode. as the device receives the clock, values written in twi_cwgr are not taken into account. 31.10.4 receiving data after a start or repeated start condition is detected and if the address sent by the master matches with the slave addre ss programmed in the sadr (slave address) field, svacc (slave access) flag is set and svread (slave read) indicates the direction of the transfer. svacc remains high until a stop condition or a repeated start is detected. when such a condition is detected, eosacc (end of slave access) flag is set. 31.10.4.1 read sequence in the case of a read sequence (svread is high), twi transfers data written in the twi_thr (twi transmit holding register) until a stop condition or a repeated _start + an address different from sadr is detected. note that at the end of the read sequence txcomp (transmis- sion complete) flag is set and svacc reset. as soon as data is written in the twi_t hr, txrdy (transmit holding register ready) flag is reset, and it is set when the shift register is empty and the sent data acknowledged or not. if the data is not acknowledged, the nack flag is set. host with twi interface twd twck lcd controller slave 1 slave 2 slave 3 rr vdd host with twi interface host with twi interface master
504 6438fCatarmC21-jun-10 at91sam9g45 note that a stop or a repeated start always follows a nack. see figure 31-25 on page 505 . 31.10.4.2 write sequence in the case of a write sequence (svread is low), the rxrdy (receive holding register ready) flag is set as soon as a character has been received in the twi_rhr (twi receive holding register). rxrdy is re set when reading the twi_rhr. twi continues receiving data until a stop co ndition or a repeated_start + an address dif- ferent from sadr is detected. note that at the end of the write sequence txcomp flag is set and svacc reset. see figure 31-26 on page 505 . 31.10.4.3 clock synchronization sequence in the case where twi_thr or twi_rhr is not written/read in time, twi performs a clock synchronization. clock stretching information is given by the sclws (clock wait state) bit. see figure 31-28 on page 507 and figure 31-29 on page 508 . 31.10.4.4 general call in the case where a general call is perfor med, gacc (general call access) flag is set. after gacc is set, it is up to the programmer to interpret the meaning of the general call and to decode the new address programming sequence. see figure 31-27 on page 506 . 31.10.4.5 31.10.5 data transfer 31.10.5.1 read operation the read mode is defined as a data requirement from the master. after a start or a repeated start condition is detected, the decoding of the address starts. if the slave address (sadr) is decoded, svacc is set and svread indicates the direc- tion of the transfer. until a stop or repeated start condition is detected, twi continues sending data loaded in the twi_thr register. if a stop condition or a repeated start + an address different from sadr is detected, svacc is reset. figure 31-25 on page 505 describes the write operation.
505 6438fCatarmC21-jun-10 at91sam9g45 figure 31-25. read access ordered by a master notes: 1. when svacc is low, the state of svread becomes irrelevant. 2. txrdy is reset when data has been transmitted from twi_thr to the shift register and set when this data has been acknowledged or non acknowledged. 31.10.5.2 write operation the write mode is defined as a data transmission from the master. after a start or a repeated start, the decodi ng of the address starts . if the slave address is decoded, svacc is set and svread indicates the direction of the transfer (svread is low in this case). until a stop or repeated start condition is detected, twi stores the received data in the twi_rhr register. if a stop condition or a repeated start + an address different from sadr is detected, svacc is reset. figure 31-26 on page 505 describes the write operation. figure 31-26. write access ordered by a master notes: 1. when svacc is low, the state of svread becomes irrelevant. 2. rxrdy is set when data has been transmitted from the shift register to the twi_rhr and reset when this data is read. write thr read rhr svread has to be taken into account only while svacc is active twd txrdy nack svacc svread eosvacc sadr s adr r na r a data a a data na s/sr data na p/s/sr sadr matches, twi answers with an ack sadr does not match, twi answers with a nack ack/nack from the master rxrdy read rhr svread has to be taken into account only while svacc is active twd svacc svread eosvacc sadr does not match, twi answers with a nack sadr s adr w na w a data a a data na s/sr data na p/s/sr sadr matches, twi answers with an ack
506 6438fCatarmC21-jun-10 at91sam9g45 31.10.5.3 general call the general call is performed in order to change the address of the slave. if a general call is detected, gacc is set. after the detection of general call, it is up to the programmer to decode the commands which come afterwards. in case of a write command, the programmer has to decode the programming sequence and program a new sadr if the programming sequence matches. figure 31-27 on page 506 describes the general call access. figure 31-27. master performs a general call note: this method allows the user to create an own programming sequence by choosing the program- ming bytes and the number of them. the programming sequence has to be provided to the master. 0000000 + w general call p s a general call reset or write dadd a new sadr data 1 a data 2 a a new sadr programming sequence txd gcacc svacc reset command = 00000110x write command = 00000100x reset after read
507 6438fCatarmC21-jun-10 at91sam9g45 31.10.5.4 clock synchronization in both read and write modes, it may happen that twi_thr/tw i_rhr buffer is not filled /emp- tied before the emission/reception of a new charac ter. in this case, to avoid sending/receiving undesired data, a clock stretching mechanism is implemented. 31.10.5.5 clock synchronization in read mode the clock is tied low if the shif t register is empty and if a stop or repeated start condition was not detected. it is tied low until the shift register is loaded. figure 31-28 on page 507 describes the clock synchronization in read mode. figure 31-28. clock synchronization in read mode notes: 1. txrdy is reset when data has been written in the twi_ thr to the shift register and set when this data has been acknowl- edged or non acknowledged. 2. at the end of the read sequence, txcomp is set after a stop or after a repeated_start + an address different from sadr. 3. sclws is automatically set when the cl ock synchronization mechanism is started. data 1 the clock is stretched after the ack, the state of twd is undefined during clock stretching sclws svacc svread txrdy twck twi_thr txcomp the data is memorized in twi_thr until a new value is written twi_thr is transmitted to the shift register ack or nack from the master data 0 data 0 data 2 1 2 1 clock is tied low by the twi as long as thr is empty s sadr s r data 0 a a data 1 a data 2 na s xxxxxxx 2 write thr as soon as a start is detected
508 6438fCatarmC21-jun-10 at91sam9g45 31.10.5.6 clock synchronization in write mode the clock is tied low if the shift regi ster and the twi_rhr is full. if a stop or repeated_start condition was not detected , it is tied low until twi_rhr is read. figure 31-29 on page 508 describes the clock synchronization in read mode. figure 31-29. clock synchronization in write mode notes: 1. at the end of the read sequence, txcomp is set after a stop or after a repeated_start + an address different from sadr. 2. sclws is automatically set when the cl ock synchronization mechanism is started and automatically reset when the mecha- nism is finished. rd data0 rd data1 rd data2 svacc svread rxrdy sclws txcomp data 1 data 2 scl is stretched on the last bit of data1 as soon as a start is detected twck twd twi_rhr clock is tied low by the twi as long as rhr is full data0 is not read in the rhr adr s sadr w a data 0 a a data 2 data 1 s na
509 6438fCatarmC21-jun-10 at91sam9g45 31.10.5.7 reversal after a repeated start 31.10.5.8 reversal of read to write the master initiates the communication by a read command and finishes it by a write command. figure 31-30 on page 509 describes the repeated start + reversal from read to write mode. figure 31-30. repeated start + reversal from read to write mode 1. txcomp is only set at the end of the transmission because after the repeated start, sadr is detected again. 31.10.5.9 reversal of write to read the master initiates the communication by a write command and finishes it by a read com- mand. figure 31-31 on page 509 describes the repeated start + reversal from write to read mode. figure 31-31. repeated start + reversal from write to read mode notes: 1. in this case, if twi_thr has not bee n written at the end of the read command, the clock is automatically stretched befo re the ack. 2. txcomp is only set at the end of the transmission because after the repeated st art, sadr is detected again. s sadr r a data 0 a data 1 sadr sr na w a data 2 a data 3 a p cleared after read data 0 data 1 data 2 data 3 svacc svread twd twi_thr twi_rhr eosacc txrdy rxrdy txcomp as soon as a start is detected s sadr w a data 0 a data 1 sadr sr a r a data 2 a data 3 n a p cleared after read data 0 data 2 data 3 data 1 txcomp txrdy rxrdy as soon as a start is detected read twi_rhr svacc svread twd twi_rhr twi_thr eosacc
510 6438fCatarmC21-jun-10 at91sam9g45 31.10.6 read write flowcharts the flowchart shown in figure 31-32 on page 510 gives an example of read and write operations in slave mode. a polling or interr upt method can be used to check the status bits. the interrupt method requires that the interrupt enable register (twi_ier) be configured first. figure 31-32. read write flowchart in slave mode set the slave mode: sadr + msdis + sven svacc = 1 ? txcomp = 1 ? gacc = 1 ? decoding of the programming sequence prog seq ok ? change sadr svread = 0 ? read status register rxrdy= 0 ? read twi_rhr txrdy= 1 ? eosacc = 1 ? write in twi_thr end general call treatment no no no no no no no no
511 6438fCatarmC21-jun-10 at91sam9g45 31.11 two-wire interface (twi) user interface table 31-6. register mapping offset register name access reset 0x00 control register twi_cr write-only n / a 0x04 master mode register twi_mmr read-write 0x00000000 0x08 slave mode register twi_smr read-write 0x00000000 0x0c internal address register twi_iadr read-write 0x00000000 0x10 clock waveform generator register twi_cwgr read-write 0x00000000 0x20 status register twi_sr read-only 0x0000f009 0x24 interrupt enable register twi_ier write-only n / a 0x28 interrupt disable register twi_idr write-only n / a 0x2c interrupt mask register twi_imr read-only 0x00000000 0x30 receive holding register twi_rhr read-only 0x00000000 0x34 transmit holding register twi_thr write-only 0x00000000 0x38 - 0xfc reserved C C C CCC
512 6438fCatarmC21-jun-10 at91sam9g45 31.11.1 twi control register name: twi_cr addresses: 0xfff84000 (0), 0xfff88000 (1) access: write-only reset: 0x00000000 ? start: send a start condition 0 = no effect. 1 = a frame beginning with a start bit is transmitted according to the features defined in the mode register. this action is necessary when the twi peripheral wants to read data from a slave. when configured in master mode with a write operation, a frame is sent as soon as the user writes a character in the transmit holding register (twi_thr). ? stop: send a stop condition 0 = no effect. 1 = stop condition is sent just after completing the current byte transmission in master read mode. C in single data byte master read, the start and stop must both be set. C in multiple data bytes master read, the stop must be set after the last data received but one. C in master read mode, if a nack bit is received, the stop is automatically performed. C in master data write operation, a st op condition will be sent after the tr ansmission of the current data is finished. ? msen: twi master mode enabled 0 = no effect. 1 = if msdis = 0, the master mode is enabled. note: switching from slave to master mo de is only permitted when txcomp = 1. ? msdis: twi master mode disabled 0 = no effect. 1 = the master mode is disabled, all pending data is transmitted. the shifter and holding characters (if it contains data) are transmitted in case of write operation. in read operation, the character being transferred must be completely received before disabling. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 swrst quick svdis sven msdis msen stop start
513 6438fCatarmC21-jun-10 at91sam9g45 ? sven: twi slave mode enabled 0 = no effect. 1 = if svdis = 0, the slave mode is enabled. note: switching from master to slave mode is only permitted when txcomp = 1. ? svdis: twi slave mode disabled 0 = no effect. 1 = the slave mode is disabled. the shifter and holding characte rs (if it contains data) are transmitted in case of read oper- ation. in write operation, the character being transferred must be completely received before disabling. ? quick: smbus quick command 0 = no effect. 1 = if master mode is enabled, a smbus quick command is sent. ? swrst: software reset 0 = no effect. 1 = equivalent to a system reset.
514 6438fCatarmC21-jun-10 at91sam9g45 31.11.2 twi master mode register name: twi_mmr addresses: 0xfff84004 (0), 0xfff88004 (1) access: read-write reset: 0x00000000 ? iadrsz: internal device address size ? mread: master read direction 0 = master write direction. 1 = master read direction. ? dadr: device address the device address is used to access slave devices in read or write mode. those bits are only used in master mode. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 Cdadr 15 14 13 12 11 10 9 8 CCCmreadCC iadrsz 76543210 CCCCCCCC iadrsz[9:8] 0 0 no internal device address 0 1 one-byte internal device address 1 0 two-byte internal device address 1 1 three-byte internal device address
515 6438fCatarmC21-jun-10 at91sam9g45 31.11.3 twi slave mode register name: twi_smr addresses: 0xfff84008 (0), 0xfff88008 (1) access: read-write reset: 0x00000000 ? sadr: slave address the slave device address is used in slav e mode in order to be accessed by master devices in read or write mode. sadr must be programmed before enabling the slave mode or after a general call. writes at other times have no effect. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 Csadr 15 14 13 12 11 10 9 8 CCCCCC 76543210 CCCCCCCC
516 6438fCatarmC21-jun-10 at91sam9g45 31.11.4 twi internal address register name: twi_iadr addresses: 0xfff8400c (0), 0xfff8800c (1) access: read-write reset: 0x00000000 ? iadr: internal address 0, 1, 2 or 3 bytes depending on iadrsz. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 iadr 15 14 13 12 11 10 9 8 iadr 76543210 iadr
517 6438fCatarmC21-jun-10 at91sam9g45 31.11.5 twi clock waveform generator register name: twi_cwgr addresses: 0xfff84010 (0), 0xfff88010 (1) access: read-write reset: 0x00000000 twi_cwgr is only used in master mode. ? cldiv: clock low divider the scl low period is defined as follows: ? chdiv: clock high divider the scl high period is defined as follows: ? ckdiv: clock divider the ckdiv is used to increase both scl high and low periods. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 ckdiv 15 14 13 12 11 10 9 8 chdiv 76543210 cldiv t low cldiv ( 2 ckdiv () 4 ) + t mck = t high chdiv ( 2 ckdiv () 4 ) + t mck =
518 6438fCatarmC21-jun-10 at91sam9g45 31.11.6 twi status register name: twi_sr addresses: 0xfff84020 (0), 0xfff88020 (1) access: read-only reset: 0x0000f009 ? txcomp: transmission completed (automatically set / reset) txcomp used in master mode : 0 = during the length of the current frame. 1 = when both holding and shifter registers are empty and stop condition has been sent. txcomp behavior in master mode can be seen in figure 31-8 on page 490 and in figure 31-10 on page 491 . txcomp used in slave mode : 0 = as soon as a start is detected. 1 = after a stop or a repeated start + an address different from sadr is detected. txcomp behavior in slave mode can be seen in figure 31-28 on page 507 , figure 31-29 on page 508 , figure 31-30 on page 509 and figure 31-31 on page 509 . ? rxrdy: receive holding register ready (automatically set / reset) 0 = no character has been received since the last twi_rhr read operation. 1 = a byte has been received in the twi_rhr since the last read. rxrdy behavior in master mode can be seen in figure 31-10 on page 491 . rxrdy behavior in slave mode can be seen in figure 31-26 on page 505 , figure 31-29 on page 508 , figure 31-30 on page 509 and figure 31-31 on page 509 . ? txrdy: transmit holding register ready (automatically set / reset) txrdy used in master mode : 0 = the transmit holding register has not been transferred into shift register. set to 0 when writing into twi_thr register. 1 = as soon as a data byte is transferred from twi_thr to inte rnal shifter or if a nack erro r is detected, txrdy is set at the same time as txcomp and nack. txrdy is also set when msen is set (enable twi). txrdy behavior in master mode can be seen in figure 31-8 on page 490 . 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 eosacc sclws arblst nack 76543210 C ovre gacc svacc svread txrdy rxrdy txcomp
519 6438fCatarmC21-jun-10 at91sam9g45 txrdy used in slave mode : 0 = as soon as data is written in the twi_thr, until this data has been transmitted and acknowledged (ack or nack). 1 = it indicates that the twi_thr is empty and that data has been transmitted and acknowledged. if txrdy is high and if a nack has been detected, the tr ansmission will be stopped. thus when trdy = nack = 1, the programmer must not fill tw i_thr to avoid losing it. txrdy behavior in slave mode can be seen in figure 31-25 on page 505 , figure 31-28 on page 507 , figure 31-30 on page 509 and figure 31-31 on page 509 . ? svread: slave read (automatically set / reset) this bit is only used in slave mode. when svacc is low (no slave access has been detected) svread is irrelevant. 0 = indicates that a write access is performed by a master. 1 = indicates that a read access is performed by a master. svread behavior can be seen in figure 31-25 on page 505 , figure 31-26 on page 505 , figure 31-30 on page 509 and figure 31-31 on page 509 . ? svacc: slave access (automatically set / reset) this bit is only used in slave mode. 0 = twi is not addressed. svacc is automatically cleared af ter a nack or a stop condition is detected. 1 = indicates that the address decoding sequence has matched (a master has sent sadr). svacc remains high until a nack or a stop condition is detected. svacc behavior can be seen in figure 31-25 on page 505 , figure 31-26 on page 505 , figure 31-30 on page 509 and fig- ure 31-31 on page 509 . ? gacc: general call access (clear on read) this bit is only used in slave mode. 0 = no general call has been detected. 1 = a general call has been detected. after the detection of general call, if need be, the programmer may acknowledge this access and decode the following bytes and respond according to the value of the bytes. gacc behavior can be seen in figure 31-27 on page 506 . ? ovre: overrun error (clear on read) this bit is only used in master mode. 0 = twi_rhr has not been loaded while rxrdy was set 1 = twi_rhr has been loaded while rxrdy was set. reset by read in twi_sr when txcomp is set. ? nack: not acknowledged (clear on read) nack used in master mode : 0 = each data byte has been correctly received by the far-end side twi slave component. 1 = a data byte has not been acknowledged by the sl ave component. set at the same time as txcomp.
520 6438fCatarmC21-jun-10 at91sam9g45 nack used in slave read mode : 0 = each data byte has been correctly received by the master. 1 = in read mode, a data byte has not been acknowledged by the master. when nack is set the programmer must not fill twi_thr even if txrdy is set, because it means that the master will stop the data transfer or re initiate it. note that in slave write mode all data are acknowledged by the twi. ? arblst: arbitration lost (clear on read) this bit is only used in master mode. 0: arbitration won. 1: arbitration lost. another master of the twi bus has won the multi-master arbitration. txcomp is set at the same time. ? sclws: clock wait state (automatically set / reset) this bit is only used in slave mode. 0 = the clock is not stretched. 1 = the clock is stretched. twi_thr / tw i_rhr buffer is not filled / emptied bef ore the emission / reception of a new character. sclws behavior can be seen in figure 31-28 on page 507 and figure 31-29 on page 508 . ? eosacc: end of slave access (clear on read) this bit is only used in slave mode. 0 = a slave access is being performing. 1 = the slave access is finished. end of slave access is automatically set as soon as svacc is reset. eosacc behavior can be seen in figure 31-30 on page 509 and figure 31-31 on page 509
521 6438fCatarmC21-jun-10 at91sam9g45 31.11.7 twi interrupt enable register name: twi_ier addresses: 0xfff84024 (0), 0xfff88024 (1) access: write-only reset: 0x00000000 ? txcomp: transmission completed interrupt enable ? rxrdy: receive holding register ready interrupt enable ? txrdy: transmit holding register ready interrupt enable ? svacc: slave access interrupt enable ? gacc: general call access interrupt enable ? ovre: overrun error interrupt enable ? nack: not acknowledge interrupt enable ? arblst: arbitration lost interrupt enable ? scl_ws: clock wait state interrupt enable ? eosacc: end of slave access interrupt enable 0 = no effect. 1 = enables the corresponding interrupt. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 eosacc scl_ws arblst nack 76543210 C ovre gacc svacc C txrdy rxrdy txcomp
522 6438fCatarmC21-jun-10 at91sam9g45 31.11.8 twi interrupt disable register name: twi_idr addresses: 0xfff84028 (0), 0xfff88028 (1) access: write-only reset: 0x00000000 ? txcomp: transmission completed interrupt disable ? rxrdy: receive holding regi ster ready interrupt disable ? txrdy: transmit holding register ready interrupt disable ? svacc: slave access interrupt disable ? gacc: general call access interrupt disable ? ovre: overrun error interrupt disable ? nack: not acknowledge interrupt disable ? arblst: arbitration lost interrupt disable ? scl_ws: clock wait state interrupt disable ? eosacc: end of slave access interrupt disable 0 = no effect. 1 = disables the corresponding interrupt. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 eosacc scl_ws arblst nack 76543210 C ovre gacc svacc C txrdy rxrdy txcomp
523 6438fCatarmC21-jun-10 at91sam9g45 31.11.9 twi interrupt mask register name: twi_imr addresses: 0xfff8402c (0), 0xfff8802c (1) access: read-only reset: 0x00000000 ? txcomp: transmission completed interrupt mask ? rxrdy: receive holding regi ster ready interrupt mask ? txrdy: transmit holding register ready interrupt mask ? svacc: slave access interrupt mask ? gacc: general call access interrupt mask ? ovre: overrun error interrupt mask ? nack: not acknowledge interrupt mask ? arblst: arbitration lost interrupt mask ? scl_ws: clock wait state interrupt mask ? eosacc: end of slave access interrupt mask 0 = the corresponding interrupt is disabled. 1 = the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 eosacc scl_ws arblst nack 76543210 C ovre gacc svacc C txrdy rxrdy txcomp
524 6438fCatarmC21-jun-10 at91sam9g45 31.11.10 twi receive holding register name: twi_rhr addresses: 0xfff84030 (0), 0xfff88030 (1) access: read-only reset: 0x00000000 ? rxdata: master or slave receive holding data 31.11.11 twi transmit holding register name: twi_thr addresses: 0xfff84034 (0), 0xfff88034 (1) access: read-write reset: 0x00000000 ? txdata: master or slave transmit holding data 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 rxdata 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 txdata
525 6438fCatarmC21-jun-10 at91sam9g45 32. timer counter (tc) 32.1 description the timer counter (tc) includes three identical 16-bit timer counter channels. each channel can be independently programmed to perform a wide range of functions including frequency measurement, event counting, interval measurement, pulse generation, delay timing and pulse width modulation. each channel has three external clock inputs, fi ve internal clock inputs and two multi-purpose input/output signals which can be configured by the user. each channel drives an internal inter- rupt signal which can be programmed to generate processor interrupts. the timer counter block has two global registers which act upon all three tc channels. the block control register allows the three channels to be started simultaneously with the same instruction. the block mode register defines the external clock inputs for each channel, allowing them to be chained. table 32-1 gives the assignment of the device timer counter clock inputs common to timer counter 0 to 2. note: 1. when slow clock is selected for master clock (css = 0 in pmc master clock register), timer_clock5 input is master clock, i.e., slow clock modified by pres and mdiv fields. 32.2 embedded characteristics ? three 16-bit timer counter channels ? wide range of functions including: C frequency measurement C event counting C interval measurement C pulse generation Cdelay timing C pulse width modulation C up/down capabilities ? each channel is user-configurable and contains: C three external clock inputs C five internal clock inputs table 32-1. timer counter clock assignment name definition timer_clock1 mck/2 timer_clock2 mck/8 timer_clock3 mck/32 timer_clock4 mck/128 timer_clock5 (1) slck
526 6438fCatarmC21-jun-10 at91sam9g45 C two multi-purpose input/output signals ? two global registers that act on all three tc channels 32.3 block diagram figure 32-1. timer counter block diagram timer/counter channel 0 timer/counter channel 1 timer/counter channel 2 syn c parallel i/o controller tc1xc1s tc0xc0s tc2xc2s int0 int1 int2 tioa0 tioa1 tioa2 tiob0 tiob1 tiob2 xc0 xc1 xc2 xc0 xc1 xc2 xc0 xc1 xc2 tclk0 tclk1 tclk2 tclk0 tclk1 tclk2 tclk0 tclk1 tclk2 tioa1 tioa2 tioa0 tioa2 tioa0 tioa1 interrupt controller tclk0 tclk1 tclk2 tioa0 tiob0 tioa1 tiob1 tioa2 tiob2 timer counter tioa tiob tioa tiob tioa tiob syn c syn c timer_clock2 timer_clock3 timer_clock4 timer_clock5 timer_clock1 table 32-2. signal name description block/channel signal name description channel signal xc0, xc1, xc2 external clock inputs tioa capture mode: timer counter input waveform mode: timer counter output tiob capture mode: timer counter input waveform mode: timer counter input/output int interrupt signal output sync synchronization input signal
527 6438fCatarmC21-jun-10 at91sam9g45 32.4 pin name list 32.5 product dependencies 32.5.1 i/o lines the pins used for interfacing the compliant ex ternal devices may be multiplexed with pio lines. the programmer must first program the pio controllers to assign the tc pins to their peripheral functions. 32.5.2 power management the tc is clocked through the power management controller (pmc), thus the programmer must first configure the pmc to enable the timer counter clock. table 32-3. tc pin list pin name description type tclk0-tclk2 external clock input input tioa0-tioa2 i/o line a i/o tiob0-tiob2 i/o line b i/o table 32-4. i/o lines instance signal i/o line peripheral tc0 tclk0 pd23 a tc0 tclk1 pd29 a tc0 tclk2 pc10 b tc0 tioa0 pd20 a tc0 tioa1 pd21 a tc0 tioa2 pd22 a tc0 tiob0 pd30 a tc0 tiob1 pd31 a tc0 tiob2 pa26 b tc1 tclk3 pa0 b tc1 tclk4 pa3 b tc1 tclk5 pd9 b tc1 tioa3 pa1 b tc1 tioa4 pa4 b tc1 tioa5 pd7 b tc1 tiob3 pa2 b tc1 tiob4 pa5 b tc1 tiob5 pd8 b
528 6438fCatarmC21-jun-10 at91sam9g45 32.5.3 interrupt the tc has an interrupt line connected to the interrupt controller (ic). handling the tc interrupt requires programming the ic before configuring the tc. 32.6 functional description 32.6.1 tc description the three channels of the timer counter are independent and identical in operation . the regis- ters for channel programming are listed in table 32-5 on page 541 . 32.6.2 16-bit counter each channel is organized around a 16-bit counter. the value of the counter is incremented at each positive edge of the selected clock. when the counter has reached the value 0xffff and passes to 0x0000, an overflow occurs and the covfs bit in tc_sr (status register) is set. the current value of the counter is accessible in real time by reading the counter value regis- ter, tc_cv. the counter can be reset by a trigger. in this case, the counter value passes to 0x0000 on the next valid edge of the selected clock. 32.6.3 clock selection at block level, input clock signals of each channel can either be connected to the external inputs tclk0, tclk1 or tclk2, or be connected to t he internal i/o signals tioa0, tioa1 or tioa2 for chaining by programming the tc_bmr (block mode). see figure 32-2 clock chaining selection . each channel can independently select an internal or external clock source for its counter: ? internal clock signals: timer_cl ock1, timer_clock2, timer_clock3, timer_clock4, timer_clock5 ? external clock signals: xc0, xc1 or xc2 this selection is made by the tcclks bits in the tc channel mode register. the selected clock can be inverted with the clki bit in tc_cmr. this allows counting on the opposite edges of the clock. the burst function allows the clock to be validat ed when an external signal is high. the burst parameter in the mode register defines this signal (none, xc0, xc1, xc2). see figure 32-3 clock selection note: in all cases, if an external clock is used, the du ration of each of its leve ls must be longer than the master clock period. the external clock frequen cy must be at least 2.5 times lower than the mas- ter clock
529 6438fCatarmC21-jun-10 at91sam9g45 figure 32-2. clock chaining selection figure 32-3. clock selection timer/counter channel 0 sync tc0xc0s tioa0 tiob0 xc0 xc1 = tclk1 xc2 = tclk2 tclk0 tioa1 tioa2 timer/counter channel 1 sync tc1xc1s tioa1 tiob1 xc0 = tclk2 xc1 xc2 = tclk2 tclk1 tioa0 tioa2 timer/counter channel 2 sync tc2xc2s tioa2 tiob2 xc0 = tclk0 xc1 = tclk1 xc2 tclk2 tioa0 tioa1 timer_clock1 timer_clock2 timer_clock3 timer_clock4 timer_clock5 xc0 xc1 xc2 tcclks clki burst 1 selected clock
530 6438fCatarmC21-jun-10 at91sam9g45 32.6.4 clock control the clock of each counter can be controlled in two different ways: it can be enabled/disabled and started/stopped. see figure 32-4 . ? the clock can be enabled or disabled by the user with the clken and the clkdis commands in the control register. in capture mode it can be disabled by an rb load event if ldbdis is set to 1 in tc_cmr. in waveform mode, it can be disabled by an rc compare event if cpcdis is set to 1 in tc_cmr. when disabled, the start or the stop actions have no effect: only a clken command in the control register can re-enable the clock. when the clock is enabled, the clksta bit is set in the status register. ? the clock can also be started or stopped: a trigger (software, synchro, external or compare) always starts the clock. the clock can be stopped by an rb load event in capture mode (ldbstop = 1 in tc_cmr) or a rc compare event in waveform mode (cpcstop = 1 in tc_cmr). the start and the stop commands have effect only if the clock is enabled. figure 32-4. clock control 32.6.5 tc operating modes each channel can independently operate in two different modes: ? capture mode provides measurement on signals. ? waveform mode provides wave generation. the tc operating mode is prog rammed with the wave bit in th e tc channel mode register. in capture mode, tioa and tiob are configured as inputs. in waveform mode, tioa is always configured to be an output and tiob is an output if it is not selected to be the external trigger. 32.6.6 trigger a trigger resets the counter and starts the counter clock. three types of triggers are common to both modes, and a fourth external trigger is available to each mode. qs r s r q clksta clken clkdis stop event disable event counter clock selected clock trigger
531 6438fCatarmC21-jun-10 at91sam9g45 regardless of the trigger used, it will be taken into account at the following active edge of the selected clock. this means that the counter value can be read differently from zero just after a trigger, especially when a low frequency signal is selected as the clock. the following triggers are common to both modes: ? software trigger: each channel has a software trigger, available by setting swtrg in tc_ccr. ? sync: each channel has a synchronization si gnal sync. when asserted, this signal has the same effect as a software trigger. the sync signals of all channels are asserted simultaneously by writing tc_bcr (block control) with sync set. ? compare rc trigger: rc is implemented in each channel and can provide a trigger when the counter value matches the rc val ue if cpctrg is set in tc_cmr. the channel can also be configured to have an external trigger. in capture mode, the external trigger signal can be selected between tioa and tiob. in waveform mode, an external event can be programmed on one of the following signals: tiob, xc0, xc1 or xc2. this external event can then be programmed to perform a trigger by setting enetrg in tc_cmr. if an external trigger is used, the duration of the pulses must be longer than the master clock period in order to be detected. 32.6.7 capture operating mode this mode is entered by clearing the wave parameter in tc_cmr (channel mode register). capture mode allows the tc channel to perform measurements such as pulse timing, fre- quency, period, duty cycle and phase on tioa and tiob sig nals which are considered as inputs. figure 32-5 shows the configuration of the tc channel when programmed in capture mode. 32.6.8 capture registers a and b registers a and b (ra and rb) are used as capture registers. this means that they can be loaded with the counter value when a progr ammable event occurs on the signal tioa. the ldra parameter in tc_cmr defines the tioa edge for the loading of register a, and the ldrb parameter defines the tioa edge for the loading of register b. ra is loaded only if it has not been loaded since the last trigger or if rb has been loaded since the last loading of ra. rb is loaded only if ra has been loaded sinc e the last trigger or t he last loading of rb. loading ra or rb before the read of the last value loaded sets the overrun error flag (lovrs) in tc_sr (status register). in this case, the old value is overwritten. 32.6.9 trigger conditions in addition to the sync signal, the software trigger and the rc compare trigger, an external trig- ger can be defined. the abetrg bit in tc_cmr selects tioa or tiob input signal as an external trigger. the etrgedg parameter defines the ed ge (rising, falling or both) det ected to genera te an external trigger. if etrgedg = 0 (none), the external trigger is disabled.
532 6438fCatarmC21-jun-10 at91sam9g45 figure 32-5. capture mode timer_clock1 timer_clock2 timer_clock3 timer_clock4 timer_clock5 xc0 xc1 xc2 tcclks clki qs r s r q clksta clken clkdis burst tiob register c capture register a capture register b compare rc = 16-bit counter abetrg swtrg etrgedg cpctrg tc1_imr trig ldrbs ldras etrgs tc1_sr lovrs covfs sync 1 mtiob tioa mtioa ldra ldbstop if ra is not loaded or rb is loaded if ra is loaded ldbdis cpcs int edge detector edge detector ldrb edge detector clk ovf reset timer/counter channel
533 6438fCatarmC21-jun-10 at91sam9g45 32.6.10 waveform operating mode waveform operating mode is entered by setting the wave parameter in tc_cmr (channel mode register). in waveform operating mode the tc channel generates 1 or 2 pwm signals with the same fre- quency and independently programmable duty cycles , or generates differe nt types of one-shot or repetitive pulses. in this mode, tioa is configured as an output and tiob is defined as an output if it is not used as an external event ( eevt parameter in tc_cmr). figure 32-6 shows the configuration of the tc channel when programmed in waveform operat- ing mode. 32.6.11 waveform selection depending on the wavsel parameter in tc_c mr (channel mode register), the behavior of tc_cv varies. with any selection, ra, rb and rc can all be used as compare registers. ra compare is used to control the tioa output, rb compare is used to control the tiob output (if correctly configured) and rc compare is used to control tioa and/or tiob outputs.
534 6438fCatarmC21-jun-10 at91sam9g45 figure 32-6. waveform mode tcclks clki qs r s r q clksta clken clkdis cpcdis burst tiob register a register b register c compare ra = compare rb = compare rc = cpcstop 16-bit counter eevt eevtedg sync swtrg enetrg wavsel tc1_imr trig acpc acpa aeevt aswtrg bcpc bcpb beevt bswtrg tioa mtioa tiob mtiob cpas covfs etrgs tc1_sr cpcs cpbs clk ovf reset output controller output controller int 1 edge detector timer/counter channel timer_clock1 timer_clock2 timer_clock3 timer_clock4 timer_clock5 xc0 xc1 xc2 wavsel
535 6438fCatarmC21-jun-10 at91sam9g45 32.6.11.1 wavsel = 00 when wavsel = 00, the value of tc_cv is incr emented from 0 to 0x ffff. once 0xffff has been reached, the value of tc_cv is reset. incrementation of tc_cv starts again and the cycle continues. see figure 32-7 . an external event trigger or a software trigger can reset the value of tc_cv. it is important to note that the trigger may occur at any time. see figure 32-8 . rc compare cannot be programmed to generate a trigger in this configuration. at the same time, rc compare can stop the counter clock (cpcstop = 1 in tc_cmr) and/or disable the counter clock (cpcdis = 1 in tc_cmr). figure 32-7. wavsel= 00 without trigger time counter value r c r b r a tiob tioa counter cleared by compare match with 0xffff 0xffff waveform examples
536 6438fCatarmC21-jun-10 at91sam9g45 figure 32-8. wavsel= 00 with trigger 32.6.11.2 wavsel = 10 when wavsel = 10, the value of tc_cv is incremented from 0 to the value of rc, then auto- matically reset on a rc compare. once the value of tc_cv has been reset, it is then incremented and so on. see figure 32-9 . it is important to note that tc_cv can be reset at any time by an external event or a software trigger if both are programmed correctly. see figure 32-10 . in addition, rc compare can stop the counter clock (cpcstop = 1 in tc_cmr) and/or disable the counter clock (cpcdis = 1 in tc_cmr). figure 32-9. wavsel = 10 without trigger time counter value r c r b r a tiob tioa counter cleared by compare match with 0xffff 0xffff waveform examples counter cleared by trigger time counter value r c r b r a tiob tioa counter cleared by compare match with rc 0xffff waveform examples
537 6438fCatarmC21-jun-10 at91sam9g45 figure 32-10. wavsel = 10 with trigger 32.6.11.3 wavsel = 01 when wavsel = 01, the value of tc_cv is incremented from 0 to 0xffff. once 0xffff is reached, the value of tc_cv is decremented to 0, then re-incremented to 0xffff and so on. see figure 32-11 . a trigger such as an external event or a software trigger can modify tc_cv at any time. if a trig- ger occurs while tc_cv is incrementing, tc_cv then decrements. if a trigger is received while tc_cv is decrementing, tc_cv then increments. see figure 32-12 . rc compare cannot be programmed to generate a trigger in this configuration. at the same time, rc compare can stop the counter clock (cpcstop = 1) and/or disable the counter clock (cpcdis = 1). time counter value r c r b r a tiob tioa counter cleared by compare match with rc 0xffff waveform examples counter cleared by trigger
538 6438fCatarmC21-jun-10 at91sam9g45 figure 32-11. wavsel = 01 without trigger figure 32-12. wavsel = 01 with trigger 32.6.11.4 wavsel = 11 when wavsel = 11, the value of tc_cv is incremented from 0 to rc. once rc is reached, the value of tc_cv is decremented to 0, then re-incremented to rc and so on. see figure 32-13 . a trigger such as an external event or a software trigger can modify tc_cv at any time. if a trig- ger occurs while tc_cv is incrementing, tc_cv then decrements. if a trigger is received while tc_cv is decrementing, tc_cv then increments. see figure 32-14 . rc compare can stop the counter clock (cpcstop = 1) and/or disable the counter clock (cpcdis = 1). time counter value r c r b r a tiob tioa counter decremented by compare match with 0xffff 0xffff waveform examples time counter value tiob tioa counter decremented by compare match with 0xffff 0xffff waveform examples counter decremented by trigger counter incremented by trigger r c r b r a
539 6438fCatarmC21-jun-10 at91sam9g45 figure 32-13. wavsel = 11 without trigger figure 32-14. wavsel = 11 with trigger time counter value r c r b r a tiob tioa counter decremented by compare match with rc 0xffff waveform examples time counter value tiob tioa counter decremented by compare match with rc 0xffff waveform examples counter decremented by trigger counter incremented by trigger r c r b r a
540 6438fCatarmC21-jun-10 at91sam9g45 32.6.12 external event/trigger conditions an external event can be programmed to be detected on one of the clock sources (xc0, xc1, xc2) or tiob. the external event selected can then be used as a trigger. the eevt parameter in tc_cmr selects the external tr igger. the eevtedg parameter defines the trigger edge for each of the possible external triggers (ris ing, falling or both). if eevtedg is cleared (none), no external event is defined. if tiob is defined as an external event signal (eevt = 0), tiob is no longer used as an output and the compare register b is not used to generate waveforms and subsequently no irqs. in this case the tc channel can only generate a waveform on tioa. when an external event is defined, it can be used as a trigger by setting bit enetrg in tc_cmr. as in capture mode, the sync signal and the softw are trigger are also available as triggers. rc compare can also be used as a trigger depending on the parameter wavsel. 32.6.13 output controller the output controller defines the output level changes on tioa and tiob following an event. tiob control is used only if tiob is defin ed as output (not as an external event). the following events control tioa and tiob: software trigger, external event and rc compare. ra compare controls tioa and rb compare controls tiob. each of these events can be pro- grammed to set, clear or toggle the output as defined in the corresponding parameter in tc_cmr.
541 6438fCatarmC21-jun-10 at91sam9g45 32.7 timer counter (tc) user interface notes: 1. channel index ranges from 0 to 2. 2. read-only if wave = 0 table 32-5. register mapping offset (1) register name access reset 0x00 + channel * 0x40 + 0x00 channel control register tc_ccr write-only C 0x00 + channel * 0x40 + 0x04 channel mode register tc_cmr read-write 0 0x00 + channel * 0x40 + 0x08 reserved 0x00 + channel * 0x40 + 0x0c reserved 0x00 + channel * 0x40 + 0x10 counter value tc_cv read-only 0 0x00 + channel * 0x40 + 0x14 register a tc_ra read-write (2) 0 0x00 + channel * 0x40 + 0x18 register b tc_rb read-write (2) 0 0x00 + channel * 0x40 + 0x1c register c tc_rc read-write 0 0x00 + channel * 0x40 + 0x20 status register tc_sr read-only 0 0x00 + channel * 0x40 + 0x24 interrupt enable register tc_ier write-only C 0x00 + channel * 0x40 + 0x28 interrupt disable register tc_idr write-only C 0x00 + channel * 0x40 + 0x2c interrupt mask register tc_imr read-only 0 0xc0 block control register tc_bcr write-only C 0xc4 block mode register tc_bmr read-write 0 0xd8 reserved 0xe4 reserved 0xfc reserved C C C
542 6438fCatarmC21-jun-10 at91sam9g45 32.7.1 tc block control register name: tc_bcr addresses: 0xfff7c0c0 (0), 0xfffd40c0 (1) access: write-only ? sync: synchro command 0 = no effect. 1 = asserts the sync signal which generates a software trigger simultaneously for each of the channels. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCsync
543 6438fCatarmC21-jun-10 at91sam9g45 32.7.2 tc block mode register name: tc_bmr addresses: 0xfff7c0c4 (0), 0xfffd40c4 (1) access: read-write ? tc0xc0s: external clock signal 0 selection ? tc1xc1s: external clock signal 1 selection ? tc2xc2s: external clock signal 2 selection 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C tc2xc2s tc1xc1s tc0xc0s tc0xc0s signal connected to xc0 00tclk0 0 1 none 10tioa1 11tioa2 tc1xc1s signal connected to xc1 00tclk1 0 1 none 10tioa0 11tioa2 tc2xc2s signal connected to xc2 00tclk2 0 1 none 10tioa0 11tioa1
544 6438fCatarmC21-jun-10 at91sam9g45 32.7.3 tc channel control register name: tc_ccrx [x=0..2] addresses: 0xfff7c000 (0)[0], 0xfff7c040 (0)[1], 0xfff 7c080 (0)[2], 0xfffd4000 (1)[0], 0xfffd4040 (1)[1], 0xfffd4080 (1)[2] access: write-only ? clken: counter clock enable command 0 = no effect. 1 = enables the clock if clkdis is not 1. ? clkdis: counter clock disable command 0 = no effect. 1 = disables the clock. ? swtrg: software trigger command 0 = no effect. 1 = a software trigger is performed: the counter is reset and the clock is started. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCswtrgclkdisclken
545 6438fCatarmC21-jun-10 at91sam9g45 32.7.4 tc channel mode register: capture mode name: tc_cmrx [x=0..2] (wave = 0) addresses: 0xfff7c004 (0)[0], 0xfff7c044 (0)[1], 0xfff7c084 (0)[2], 0xfffd4004 (1)[0], 0xfffd4044 (1)[1], 0xfffd4084 (1)[2] access: read-write ? tcclks: clock selection ? clki: clock invert 0 = counter is incremented on rising edge of the clock. 1 = counter is incremented on falling edge of the clock. ? burst: burst signal selection ? ldbstop: counter clock stopped with rb loading 0 = counter clock is not stopped when rb loading occurs. 1 = counter clock is stopped when rb loading occurs. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 C C C C ldrb ldra 15 14 13 12 11 10 9 8 wave cpctrg C C C abetrg etrgedg 76543210 ldbdis ldbstop burst clki tcclks tcclks clock selected 0 0 0 timer_clock1 0 0 1 timer_clock2 0 1 0 timer_clock3 0 1 1 timer_clock4 1 0 0 timer_clock5 101xc0 110xc1 111xc2 burst 0 0 the clock is not gated by an external signal. 0 1 xc0 is anded with the selected clock. 1 0 xc1 is anded with the selected clock. 1 1 xc2 is anded with the selected clock.
546 6438fCatarmC21-jun-10 at91sam9g45 ? ldbdis: counter clock disable with rb loading 0 = counter clock is not disabled when rb loading occurs. 1 = counter clock is disabled when rb loading occurs. ? etrgedg: external trigger edge selection ? abetrg: tioa or tiob external trigger selection 0 = tiob is used as an external trigger. 1 = tioa is used as an external trigger. ? cpctrg: rc compare trigger enable 0 = rc compare has no effect on the counter and its clock. 1 = rc compare resets the counter and starts the counter clock. ?wave 0 = capture mode is enabled. 1 = capture mode is disabled (waveform mode is enabled). ? ldra: ra loading selection ? ldrb: rb loading selection etrgedg edge 0 0 none 0 1 rising edge 1 0 falling edge 1 1 each edge ldra edge 0 0 none 0 1 rising edge of tioa 1 0 falling edge of tioa 1 1 each edge of tioa ldrb edge 0 0 none 0 1 rising edge of tioa 1 0 falling edge of tioa 1 1 each edge of tioa
547 6438fCatarmC21-jun-10 at91sam9g45 32.7.5 tc channel mode register: waveform mode name: tc_cmrx [x=0..2] (wave = 1) addresses: 0xfff7c004 (0)[0], 0xfff7c044 (0)[1], 0xfff7c084 (0)[2], 0xfffd4004 (1)[0], 0xfffd4044 (1)[1], 0xfffd4084 (1)[2] access: read-write ? tcclks: clock selection ? clki: clock invert 0 = counter is incremented on rising edge of the clock. 1 = counter is incremented on falling edge of the clock. ? burst: burst signal selection ? cpcstop: counter clock stopped with rc compare 0 = counter clock is not stopped when counter reaches rc. 1 = counter clock is stopped when counter reaches rc. 31 30 29 28 27 26 25 24 bswtrg beevt bcpc bcpb 23 22 21 20 19 18 17 16 aswtrg aeevt acpc acpa 15 14 13 12 11 10 9 8 wave wavsel enetrg eevt eevtedg 76543210 cpcdis cpcstop burst clki tcclks tcclks clock selected 0 0 0 timer_clock1 0 0 1 timer_clock2 0 1 0 timer_clock3 0 1 1 timer_clock4 1 0 0 timer_clock5 101xc0 110xc1 111xc2 burst 0 0 the clock is not gated by an external signal. 0 1 xc0 is anded with the selected clock. 1 0 xc1 is anded with the selected clock. 1 1 xc2 is anded with the selected clock.
548 6438fCatarmC21-jun-10 at91sam9g45 ? cpcdis: counter clock disable with rc compare 0 = counter clock is not disabl ed when counter reaches rc. 1 = counter clock is disabled when counter reaches rc. ? eevtedg: external ev ent edge selection ? eevt: external event selection note: 1. if tiob is chosen as the external event signal, it is conf igured as an input and no longer generates waveforms and subse- quently no irqs . ? enetrg: external event trigger enable 0 = the external event has no effect on the counter and its clock. in this case, the selected external event only controls the tioa output. 1 = the external event resets the counter and starts the counter clock. ? wavsel: waveform selection ?wave 0 = waveform mode is disabled (capture mode is enabled). 1 = waveform mode is enabled. eevtedg edge 0 0 none 0 1 rising edge 1 0 falling edge 1 1 each edge eevt signal selected as exte rnal event tiob direction 0 0 tiob input (1) 0 1 xc0 output 1 0 xc1 output 1 1 xc2 output wavsel effect 0 0 up mode without automatic trigger on rc compare 1 0 up mode with automatic trigger on rc compare 0 1 updown mode without automat ic trigger on rc compare 1 1 updown mode with automatic trigger on rc compare
549 6438fCatarmC21-jun-10 at91sam9g45 ? acpa: ra compare effect on tioa ? acpc: rc compare effect on tioa ? aeevt: external event effect on tioa ? aswtrg: software trigger effect on tioa ? bcpb: rb compare effect on tiob acpa effect 0 0 none 0 1 set 1 0 clear 1 1 toggle acpc effect 0 0 none 0 1 set 1 0 clear 1 1 toggle aeevt effect 0 0 none 0 1 set 1 0 clear 11toggle aswtrg effect 0 0 none 0 1 set 1 0 clear 1 1 toggle bcpb effect 0 0 none 0 1 set 1 0 clear 11toggle
550 6438fCatarmC21-jun-10 at91sam9g45 ? bcpc: rc compare effect on tiob ? beevt: external event effect on tiob ? bswtrg: software trigger effect on tiob bcpc effect 0 0 none 0 1 set 1 0 clear 1 1 toggle beevt effect 0 0 none 0 1 set 1 0 clear 1 1 toggle bswtrg effect 0 0 none 01set 1 0 clear 11toggle
551 6438fCatarmC21-jun-10 at91sam9g45 32.7.6 tc counter value register name: tc_cvx [x=0..2] addresses: 0xfff7c010 (0)[0], 0xfff7c050 (0)[1], 0xfff7c090 (0)[2], 0xfffd4010 (1)[0] 0xfffd4050 (1)[1], 0xfffd4090 (1)[2] access: read-only ? cv: counter value cv contains the counter value in real time. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 cv 76543210 cv
552 6438fCatarmC21-jun-10 at91sam9g45 32.7.7 tc register a name: tc_rax [x=0..2] addresses: 0xfff7c014 (0)[0], 0xfff7c054 (0)[1], 0xfff7c094 (0)[2], 0xfffd4014 (1)[0], 0xfffd4054 (1)[1], 0xfffd4094 (1)[2] access: read-only if wave = 0, read-write if wave = 1 ? ra: register a ra contains the register a value in real time. 32.7.8 tc register b name: tc_rbx [x=0..2] addresses: 0xfff7c018 (0)[0], 0xfff7c058 (0)[1], 0xfff7c098 (0)[2], 0xfffd4018 (1)[0], 0xfffd4058 (1)[1], 0xfffd4098 (1)[2] access: read-only if wave = 0, read-write if wave = 1 ? rb: register b rb contains the register b value in real time. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 ra 76543210 ra 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 rb 76543210 rb
553 6438fCatarmC21-jun-10 at91sam9g45 32.7.9 tc register c name: tc_rcx [x=0..2] addresses: 0xfff7c01c (0)[0], 0xfff7c05c (0)[1], 0xfff7c09c (0)[2], 0xfffd401c (1)[0], 0xfffd405c (1)[1], 0xfffd409c (1)[2] access: read-write ? rc: register c rc contains the register c value in real time. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 rc 76543210 rc
554 6438fCatarmC21-jun-10 at91sam9g45 32.7.10 tc status register name: tc_srx [x=0..2] addresses: 0xfff7c020 (0)[0], 0xfff7c060 (0)[1], 0xfff7c0a0 (0)[2], 0xfffd4020 (1)[0], 0xfffd4060 (1)[1], 0xfffd40a0 (1)[2] access: read-only ? covfs: counter overflow status 0 = no counter overflow has occurred since the last read of the status register. 1 = a counter overflow has occurred since the last read of the status register. ? lovrs: load overrun status 0 = load overrun has not occurred since the last read of the status register or wave = 1. 1 = ra or rb have been loaded at least twice without any read of the corresponding register since the last read of the sta- tus register, if wave = 0. ? cpas: ra compare status 0 = ra compare has not occurred since the last read of the status register or wave = 0. 1 = ra compare has occurred since the last read of the status register, if wave = 1. ? cpbs: rb compare status 0 = rb compare has not occurred since the last read of the status register or wave = 0. 1 = rb compare has occurred since the last read of the status register, if wave = 1. ? cpcs: rc compare status 0 = rc compare has not occurred since the last read of the status register. 1 = rc compare has occurred since the last read of the status register. ? ldras: ra loading status 0 = ra load has not occurred si nce the last read of the status register or wave = 1. 1 = ra load has occurred since the last re ad of the status register, if wave = 0. ? ldrbs: rb loading status 0 = rb load has not occurred si nce the last read of the status register or wave = 1. 1 = rb load has occurred since the last re ad of the status register, if wave = 0. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCmtiobmtioaclksta 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
555 6438fCatarmC21-jun-10 at91sam9g45 ? etrgs: external trigger status 0 = external trigger has not occurred sinc e the last read of the status register. 1 = external trigger has occurred since the last read of the status register. ? clksta: clock enabling status 0 = clock is disabled. 1 = clock is enabled. ? mtioa: tioa mirror 0 = tioa is low. if wave = 0, this mean s that tioa pin is low. if wave = 1, this means that tioa is driven low. 1 = tioa is high. if wave = 0, this mean s that tioa pin is high. if wave = 1, this means that ti oa is driven high. ? mtiob: tiob mirror 0 = tiob is low. if wave = 0, this mean s that tiob pin is low. if wave = 1, this means that tiob is driven low. 1 = tiob is high. if wave = 0, this mean s that tiob pin is high. if wave = 1, this means that ti ob is driven high.
556 6438fCatarmC21-jun-10 at91sam9g45 32.7.11 tc interrupt enable register name: tc_ierx [x=0..2] addresses: 0xfff7c024 (0)[0], 0xfff7c064 (0)[1], 0xfff7c0a4 (0)[2], 0xfffd4024 (1)[0], 0xfffd4064 (1)[1], 0xfffd40a4 (1)[2] access: write-only ? covfs: counter overflow 0 = no effect. 1 = enables the counter overflow interrupt. ? lovrs: load overrun 0 = no effect. 1 = enables the load overrun interrupt. ? cpas: ra compare 0 = no effect. 1 = enables the ra compare interrupt. ? cpbs: rb compare 0 = no effect. 1 = enables the rb compare interrupt. ? cpcs: rc compare 0 = no effect. 1 = enables the rc compare interrupt. ? ldras: ra loading 0 = no effect. 1 = enables the ra load interrupt. ? ldrbs: rb loading 0 = no effect. 1 = enables the rb load interrupt. ? etrgs: external trigger 0 = no effect. 1 = enables the external trigger interrupt. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
557 6438fCatarmC21-jun-10 at91sam9g45 32.7.12 tc interrupt disable register name: tc_idrx [x=0..2] addresses: 0xfff7c028 (0)[0], 0xfff7c068 (0)[1], 0xfff7c0a8 (0)[2], 0xfffd4028 (1)[0], 0xfffd4068 (1)[1], 0xfffd40a8 (1)[2] access: write-only ? covfs: counter overflow 0 = no effect. 1 = disables the counter overflow interrupt. ? lovrs: load overrun 0 = no effect. 1 = disables the load overrun interrupt (if wave = 0). ? cpas: ra compare 0 = no effect. 1 = disables the ra compare interrupt (if wave = 1). ? cpbs: rb compare 0 = no effect. 1 = disables the rb compare interrupt (if wave = 1). ? cpcs: rc compare 0 = no effect. 1 = disables the rc compare interrupt. ? ldras: ra loading 0 = no effect. 1 = disables the ra load interrupt (if wave = 0). ? ldrbs: rb loading 0 = no effect. 1 = disables the rb load interrupt (if wave = 0). ? etrgs: external trigger 0 = no effect. 1 = disables the external trigger interrupt. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
558 6438fCatarmC21-jun-10 at91sam9g45 32.7.13 tc interrupt mask register name: tc_imrx [x=0..2] addresses: 0xfff7c02c (0)[0], 0xfff7c06c (0)[1], 0xfff7c0ac (0)[2], 0xfffd402c (1)[0], 0xfffd406c (1)[1], 0xfffd40ac (1)[2] access: read-only ? covfs: counter overflow 0 = the counter overflow interrupt is disabled. 1 = the counter overflow interrupt is enabled. ? lovrs: load overrun 0 = the load overrun interrupt is disabled. 1 = the load overrun interrupt is enabled. ? cpas: ra compare 0 = the ra compare interrupt is disabled. 1 = the ra compare interrupt is enabled. ? cpbs: rb compare 0 = the rb compare interrupt is disabled. 1 = the rb compare interrupt is enabled. ? cpcs: rc compare 0 = the rc compare interrupt is disabled. 1 = the rc compare interrupt is enabled. ? ldras: ra loading 0 = the load ra interrupt is disabled. 1 = the load ra interrupt is enabled. ? ldrbs: rb loading 0 = the load rb interrupt is disabled. 1 = the load rb interrupt is enabled. ? etrgs: external trigger 0 = the external trigger interrupt is disabled. 1 = the external trigger interrupt is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
559 6438fCatarmC21-jun-10 at91sam9g45 33. universal synchronous asynchrono us receiver transmitter (usart) 33.1 description the universal synchronous asynchronous receiv er transmitter (usart) provides one full duplex universal synchronous asynchronous serial link. data frame format is widely programma- ble (data length, parity, number of stop bits) to support a maximum of standards. the receiver implements parity error, framing error and overrun error detection. the receiver time-out enables handling variable-length frames and the transmitt er timeguard facilitates communications with slow remote devices. multidrop communications are also supported through address bit han- dling in reception and transmission. the usart features three test modes: remote loopback, local loopback and automatic echo. the usart supports specific operating modes providing interfaces on rs485, lin and spi buses, with iso7816 t = 0 or t = 1 smart card slots and infrared transceivers. the hardware handshaking feature enables an out-of-band flow control by automatic management of the pins rts and cts. the usart supports the connection to the peripheral dma controller, which enables data transfers to the transmitter and from the receiver. the pdc provides chained buffer manage- ment without any intervention of the processor. 33.2 embedded characteristics ? programmable baud rate generator ? 5- to 9-bit full-duplex synchronous or asynchronous serial communications C 1, 1.5 or 2 stop bits in asynchronous mode or 1 or 2 stop bits in synchronous mode C parity generation and error detection C framing error detection, overrun error detection C msb- or lsb-first C optional break generation and detection C by 8 or by-16 over-sampling receiver frequency C hardware handshaking rts-cts C receiver time-out and transmitter timeguard C optional multi-drop mode with address generation and detection C optional manchester encoding ? rs485 with driver control signal ? iso7816, t = 0 or t = 1 protocols for interfacing with smart cards C nack handling, error counter with repetition and iteration limit ? irda modulation and demodulation C communication at up to 115.2 kbps ? test modes C remote loopback, local loopback, automatic echo
560 6438fCatarmC21-jun-10 at91sam9g45 33.3 block diagram figure 33-1. usart block diagram peripheral dma controller channel channel aic receiver usart interrupt rxd txd sck usart pio controller cts rts transmitter baud rate generator user interface pmc mck slck div mck/div apb table 33-1. spi operating mode pin usart spi slave spi master rxd rxd mosi miso txd txd miso mosi rts rts C cs cts cts cs C
561 6438fCatarmC21-jun-10 at91sam9g45 33.4 application block diagram figure 33-2. application block diagram smart card slot usart rs485 drivers differential bus irda transceivers field bus driver emv driver irda driver irlap rs232 drivers serial port serial driver ppp spi driver spi bus
562 6438fCatarmC21-jun-10 at91sam9g45 33.5 i/o lines description table 33-2. i/o line description name description type active level sck serial clock i/o txd transmit serial data or master out slave in (mosi) in spi master mode or master in slave out (miso) in spi slave mode i/o rxd receive serial data or master in slave out (miso) in spi master mode or master out slave in (mosi) in spi slave mode input cts clear to send or slave select (nss) in spi slave mode input low rts request to send or slave select (nss) in spi master mode output low
563 6438fCatarmC21-jun-10 at91sam9g45 33.6 product dependencies 33.6.1 i/o lines the pins used for interfacing the usart may be multiplexed with the pio lines. the program- mer must first program the pio controller to assign the desired usart pins to their peripheral function. if i/o lines of the usart are not used by the application, they can be used for other purposes by the pio controller. to prevent the txd line from falling when the usart is di sabled, the use of an internal pull up is mandatory. if the hardware handshaking feature is used, the internal pull up on txd must also be enabled. 33.6.2 power management the usart is not continuously clocked. the pr ogrammer must first enable the usart clock in the power management controller (pmc) before usin g the usart. however, if the application does not require usart operations, the usart clock can be stopped when not needed and be restarted later. in this case, the usart will resume its operations where it left off. configuring the usart does not require the usart clock to be enabled. table 33-3. i/o lines instance signal i/o line peripheral usart0 cts0 pb15 b usart0 rts0 pb17 b usart0 rxd0 pb18 a usart0 sck0 pb16 b usart0 txd0 pb19 a usart1 cts1 pd17 a usart1 rts1 pd16 a usart1 rxd1 pb5 a usart1 sck1 pd29 b usart1 txd1 pb4 a usart2 cts2 pc11 b usart2 rts2 pc9 b usart2 rxd2 pb7 a usart2 sck2 pd30 b usart2 txd2 pb6 a usart3 cts3 pa24 b usart3 rts3 pa23 b usart3 rxd3 pb9 a usart3 sck3 pa22 b usart3 txd3 pb8 a
564 6438fCatarmC21-jun-10 at91sam9g45 33.6.3 interrupt the usart interrupt line is connected on one of the internal sources of the advanced inter-rupt controller. using the usart interrup t requires the aic to be programmed first. note that it is not recommended to use the usart interrupt line in edge sensitive mode. 33.7 functional description the usart is capable of managing several ty pes of serial synchronous or asynchronous communications. it supports the following communication modes: ? 5- to 9-bit full-duplex asynchronous serial communication C msb- or lsb-first C 1, 1.5 or 2 stop bits C parity even, odd, marked, space or none C by 8 or by 16 over-sampling receiver frequency C optional hardware handshaking C optional break management C optional multidrop serial communication ? high-speed 5- to 9-bit full-duplex synchronous serial communication C msb- or lsb-first C 1 or 2 stop bits C parity even, odd, marked, space or none C by 8 or by 16 over-sampling frequency C optional hardware handshaking C optional break management C optional multidrop serial communication ? rs485 with driver control signal ? iso7816, t0 or t1 protocols for interfacing with smart cards C nack handling, error counter with repetition and iteration limit ? infrared irda modulation and demodulation ? spi mode ? master or slave ? serial clock programmable phase and polarity ? spi serial clock (sck) frequency up to internal clock frequency mck/4 table 33-4. peripheral ids instance id usart0 7 usart1 8 usart2 9 usart3 10
565 6438fCatarmC21-jun-10 at91sam9g45 ? lin mode ? compliant with lin 1.3 and lin 2.0 sp ecifications ? master or slave ? processing of frames with up to 256 data bytes ? response data length can be configurable or defined automatica lly by the identifier ? self synchronization in slave node configuration ? automatic processing and verification of the ?synch break? an d the ?synch field? ? the ?synch break? is detected even if it is partially superimposed with a data byte ? automatic identifier parity ca lculation/sending and verification ? parity sending and verification can be disabled ? automatic checksum calculati on/sending and verification ? checksum sending and veri fication can be disabled ? support both ?classic? an d ?enhanced? checksum types ? full lin error checking and reporting ? frame slot mode: the master allocates sl ots to the scheduled frames automatically. ? generation of the wakeup signal ? test modes C remote loopback, local loopback, automatic echo
566 6438fCatarmC21-jun-10 at91sam9g45 33.7.1 baud rate generator the baud rate generator provides the bit period clock named the baud rate clock to both the receiver and the transmitter. the baud rate generator clock source can be selected by setting the usclks field in the mode register (us_mr) between: ? the master clock mck ? a division of the master clock, the divider being product dependent, but generally set to 8 ? the external clock, available on the sck pin the baud rate generator is based upon a 16-bit divider, which is programmed with the cd field of the baud rate generator register (us_brgr). if cd is programmed at 0, the baud rate generator does not generate any clock. if cd is programmed at 1, the divider is bypassed and becomes inactive. if the external sck clock is selected, the duration of the low and high levels of the signal pro- vided on the sck pin must be longer than a master clock (mck) period. the frequency of the signal provided on sck must be at least 4.5 times lower than mck. figure 33-3. baud rate generator 33.7.1.1 baud rate in asynchronous mode if the usart is programmed to operate in as ynchronous mode, the selected clock is first divided by cd, which is field programmed in the baud rate generator register (us_brgr). the resulting clock is provided to the receiv er as a sampling clock and then divided by 16 or 8, depending on the programming of the over bit in us_mr. if over is set to 1, the receiver sampling is 8 times higher than the baud rate clock. if over is cleared, the sampling is performed at 16 times the baud rate clock. the following formula performs the calculation of the baud rate. this gives a maximum baud rate of mck divided by 8, assuming that mck is the highest possi- ble clock and that over is programmed at 1. mck/div 16-bit counter 0 baud rate clock cd cd sampling divider 0 1 >1 sampling clock reserved mck sck usclks over sck sync sync usclks = 3 1 0 2 3 0 1 0 1 fidi baudrate selectedclock 82 over ? () cd () -------------------------------------------- =
567 6438fCatarmC21-jun-10 at91sam9g45 33.7.1.2 baud rate calculation example table 33-5 shows calculations of cd to obtain a baud rate at 38400 bauds for different source clock frequencies. this table also shows the actual resulting baud rate and the error. the baud rate is calculated with the following formula: the baud rate error is calculated with the following formula. it is not recommended to work with an error higher than 5%. 33.7.1.3 fractional baud rate in asynchronous mode the baud rate generator previously defined is su bject to the following limitation: the output fre- quency changes by only integer multiples of the reference frequency. an approach to this problem is to integrate a fractional n clock generator that has a high resolution. the generator architecture is modified to obtain baud rate c hanges by a fraction of the reference source clock. this fractional part is programmed with the fp field in the baud rate generator register (us_brgr). if fp is not 0, the fractional part is activated. the resolution is one eighth of the table 33-5. baud rate example (over = 0) source clock expected baud rate calculation result cd actual baud rate error mhz bit/s bit/s 3 686 400 38 400 6.00 6 38 400.00 0.00% 4 915 200 38 400 8.00 8 38 400.00 0.00% 5 000 000 38 400 8.14 8 39 062.50 1.70% 7 372 800 38 400 12.00 12 38 400.00 0.00% 8 000 000 38 400 13.02 13 38 461.54 0.16% 12 000 000 38 400 19.53 20 37 500.00 2.40% 12 288 000 38 400 20.00 20 38 400.00 0.00% 14 318 180 38 400 23.30 23 38 908.10 1.31% 14 745 600 38 400 24.00 24 38 400.00 0.00% 18 432 000 38 400 30.00 30 38 400.00 0.00% 24 000 000 38 400 39.06 39 38 461.54 0.16% 24 576 000 38 400 40.00 40 38 400.00 0.00% 25 000 000 38 400 40.69 40 38 109.76 0.76% 32 000 000 38 400 52.08 52 38 461.54 0.16% 32 768 000 38 400 53.33 53 38 641.51 0.63% 33 000 000 38 400 53.71 54 38 194.44 0.54% 40 000 000 38 400 65.10 65 38 461.54 0.16% 50 000 000 38 400 81.38 81 38 580.25 0.47% baudrate mck cd 16 ? = error 1 expectedbaudrate actualbaudrate -------------------------------------------------- - ?? ?? ? =
568 6438fCatarmC21-jun-10 at91sam9g45 clock divider. this feature is only available when using usart normal mode. the fractional baud rate is calculated using the following formula: the modified architecture is presented below: figure 33-4. fractional baud rate generator 33.7.1.4 baud rate in synchronous mode or spi mode if the usart is programmed to operate in synchronous mode, the selected clock is simply divided by the field cd in us_brgr. in synchronous mode, if the external clock is selected (usclks = 3), the clock is provided directly by the signal on the usart sck pin. no division is active. the value written in us_brgr has no effect. the external clock frequency must be at least 4.5 times lower than the system clock. in synchronous mode master (usclks = 0 or 1, clk0 set to 1), the receive part limits the sck maximum frequency to mck/4.5, when either the external clock sck or the inte rnal clock divided (mck/div) is selected, the value programmed in cd must be even if the user has to ensure a 50:50 mark/space ratio on the sck pin. if the internal clock mck is selected, the baud rate generator ensures a 50:50 duty cycle on the sck pin, even if the value programmed in cd is odd. baudrate selectedclock 82 over ? () cd fp 8 ------- + ?? ?? ?? ?? ---------------------------------------------------------------- - = mck/div 16-bit counter 0 baud rate clock cd cd sampling divider 0 1 >1 sampling clock reserved mck sck usclks over sck sync sync usclks = 3 1 0 2 3 0 1 0 1 fidi glitch-free logic modulus control fp fp baudrate selectedclock cd ------------------------------------- - =
569 6438fCatarmC21-jun-10 at91sam9g45 33.7.1.5 baud rate in iso 7816 mode the iso7816 specification defines the bit rate with the following formula: where: ? b is the bit rate ? di is the bit-rate adjustment factor ? fi is the clock frequency division factor ? f is the iso7816 clock frequency (hz) di is a binary value encoded on a 4-bit field, named di, as represented in table 33-6 . fi is a binary value encoded on a 4-bi t field, named fi, as represented in table 33-7 . table 33-8 shows the resulting fi/di ratio, which is the ratio between the iso7816 clock and the baud rate clock. if the usart is configured in iso7816 mode, th e clock selected by the usclks field in the mode register (us_mr) is first divided by the value programmed in the field cd in the baud rate generator register (us_brgr). the resulting clock can be provided to the sck pin to feed the smart card clock inputs. this means that the clko bit can be set in us_mr. this clock is then divided by the value progra mmed in the fi_di_ratio field in the fi_di_ratio register (us_fidi). this is performed by the sampling divider, which performs a division by up to 2047 in iso7816 mode. the non-integer values of the fi/di ratio are not supported and the user must program the fi_di_ratio field to a va lue as close as possible to the expected value. the fi_di_ratio field resets to the value 0x174 (372 in decimal) and is the most common divider between the iso7816 clock and the bit rate (fi = 372, di = 1). b di fi ----- - f = table 33-6. binary and decimal values for di di field 0001 0010 0011 0100 0101 0110 1000 1001 di (decimal)1 2 4 8 163212 20 table 33-7. binary and decimal values for fi fi field 0000 0001 0010 0011 0100 0101 0110 1001 1010 1011 1100 1101 fi (decimal 372 372 558 744 1116 1488 1860 512 768 1024 1536 2048 table 33-8. possible values for the fi/di ratio fi/di 372 558 774 1116 1488 1806 512 768 1024 1536 2048 1 372 558 744 1116 1488 1860 512 768 1024 1536 2048 2 186 279 372 558 744 930 256 384 512 768 1024 4 93 139.5 186 279 372 465 128 192 256 384 512 8 46.5 69.75 93 139.5 186 232.5 64 96 128 192 256 16 23.25 34.87 46.5 69.75 93 116.2 32 48 64 96 128 32 11.62 17.43 23.25 34.87 46.5 58.13 16 24 32 48 64 12 31 46.5 62 93 124 155 42.66 64 85.33 128 170.6 20 18.6 27.9 37.2 55.8 74.4 93 25.6 38.4 51.2 76.8 102.4
570 6438fCatarmC21-jun-10 at91sam9g45 figure 33-5 shows the relation between the elementary time unit, corresponding to a bit time, and the iso 7816 clock. figure 33-5. elementary time unit (etu) 33.7.2 receiver and transmitter control after reset, the receiver is disabled. the user must enable the receiver by setting the rxen bit in the control register (us_cr). however, the receiver registers can be programmed before the receiver clock is enabled. after reset, the transmitter is disabled. the user must enable it by setting the txen bit in the control register (us_cr). however, the transmitter registers can be programmed before being enabled. the receiver and the transmitter can be enabled together or independently. at any time, the software can perform a reset on the receiver or the transmitter of the usart by setting the corresponding bit, rstrx and rsttx respectively, in the control register (us_cr). the software resets clear the status flag and reset internal state machines but the user interface configuration registers hold the value configured prior to software reset. regard- less of what the receiver or the transmitter is performing, the communi cation is immediately stopped. the user can also independently disable the receiv er or the transmitter by setting rxdis and txdis respectively in us_cr. if the receiver is disabled during a character reception, the usart waits until the end of reception of the current character, then the reception is stopped. if the transmitter is disabled while it is operating, the usart waits the end of transmission of both the current character and character being stored in the transmit holding register (us_thr). if a timeguard is programmed, it is handled normally. 33.7.3 synchronous and asynchronous modes 33.7.3.1 transmitter operations the transmitter performs the same in both synchronous and asynchronous operating modes (sync = 0 or sync = 1). one start bit, up to 9 da ta bits, one optional parity bit and up to two stop bits are successively shifted out on the txd pin at each falling edge of the programmed serial clock. the number of data bits is selected by the chrl field and the mode 9 bit in the mode register (us_mr). nine bits are selected by setting the mode 9 bit regardless of the chrl field. the parity bit is set according to the par field in us_mr. the even, odd, space, marked or none parity bit can be configured. the msbf field in us _mr configures which data bit is sent first. if written at 1, the most significant bit is sent first. at 0, the less significant bit is sent first. the num- 1 etu iso7816 clock on sck iso7816 i/o line on txd fi_di_ratio iso7816 clock cycles
571 6438fCatarmC21-jun-10 at91sam9g45 ber of stop bits is selected by the nbstop fiel d in us_mr. the 1.5 stop bit is supported in asynchronous mode only. figure 33-6. character transmit the characters are sent by writing in the tran smit holding register (us_thr). the transmitter reports two status bits in the channel status register (us_csr): txrdy (transmitter ready), which indicates that us_thr is empty and txempty, which indicates that all the characters written in us_thr have been processed. when the current character processing is completed, the last character written in us_thr is transferred into the shift register of the transmitter and us_thr becomes empty, thus txrdy rises. both txrdy and txempty bits are low when the transmitter is disabled. writing a character in us_thr while txrdy is low has no effect and the written character is lost. figure 33-7. transmitter status 33.7.3.2 manchester encoder when the manchester encoder is in use, c haracters transmitted through the usart are encoded based on biphase manchester ii format. to enable this mode, set the man field in the us_mr register to 1. depending on polarity configur ation, a logic level (zero or one), is transmit- ted as a coded signal one-to-zero or zero-to-one. thus, a transition always occurs at the midpoint of each bit time. it consumes more bandwidth than the original nrz signal (2x) but the receiver has more error control since the expected input must show a change at the center of a bit cell. an example of manchester encoded sequence is: the byte 0xb1 or 10110001 encodes to 10 01 10 10 01 01 01 10, assuming the default polarity of the encoder. figure 33-8 illustrates this coding scheme. d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit example: 8-bit, parity enabled one stop baud rate clock d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock start bit write us_thr d0 d1 d2 d3 d4 d5 d6 d7 parity bit stop bit txrdy txempty
572 6438fCatarmC21-jun-10 at91sam9g45 figure 33-8. nrz to manchester encoding the manchester encoded character can also be enc apsulated by adding both a configurable preamble and a start frame delimiter pattern. depending on the configuration, the preamble is a training sequence, composed of a pre-defined pattern with a programmable length from 1 to 15 bit times. if the preamble length is set to 0, the preamble waveform is not generated prior to any character. the preamble pattern is chosen among the following sequences: all_one, all_zero, one_zero or zero_one, writing th e field tx_pp in the us_man register, the field tx_pl is used to configure the preamble length. figure 33-9 illustrates and defines the valid patterns. to improve flexibility, the encoding scheme can be configured using the tx_mpol field in the us_man register. if the tx _mpol field is set to zero (default), a logic zero is encoded with a zero-to-one transition and a logic one is encoded with a one-to-zero tran- sition. if the tx_mpol field is set to one, a logic one is encoded with a one-to-zero transition and a logic zero is encoded with a zero-to-one transition. figure 33-9. preamble patterns, default polarity assumed a start frame delimiter is to be configured using the onebit field in the us_mr register. it con- sists of a user-defined pattern that indicates the beginning of a valid data. figure 33-10 illustrates these pattern s. if the start frame delimiter, also kn own as start bit, is one bit, (onebit at 1), a logic zero is manchester encoded and in dicates that a new character is being sent seri- ally on the line. if the start frame delimiter is a synchronization pattern also referred to as sync (onebit at 0), a sequence of 3 bit times is sent serially on the line to indicate the start of a new character. the sync waveform is in itself an invalid manchester waveform as the transition nrz encoded data manchester encoded data 10110001 txd manchester encoded data txd sfd data 8 bit width "all_one" preamble manchester encoded data txd sfd data 8 bit width "all_zero" preamble manchester encoded data txd sfd data 8 bit width "zero_one" preamble manchester encoded data txd sfd data 8 bit width "one_zero" preamble
573 6438fCatarmC21-jun-10 at91sam9g45 occurs at the middle of the second bit time. tw o distinct sync patterns are used: the command sync and the data sync. the co mmand sync has a logic one level for one and a half bit times, then a transition to logic zero for the second one and a half bit times. if the modsync field in the us_mr register is set to 1, the next character is a command. if it is set to 0, the next charac- ter is a data. when direct memory access is used, the modsync field can be immediately updated with a modified character located in memory. to enable this mode, var_sync field in us_mr register must be set to 1. in this ca se, the modsync field in us_mr is bypassed and the sync configuration is held in the txsynh in the us_thr register. the usart character for- mat is modified and includes sync information. figure 33-10. start frame delimiter 33.7.3.3 drift compensation drift compensation is available only in 16x oversampling mode. an ha rdware recovery system allows a larger clock drift. to enable the ha rdware system, the bit in the usart_man register must be set. if the rxd edge is one 16x clock c ycle from the expected edge, this is considered as normal jitter and no corrective actions is taken. if the rxd event is between 4 and 2 clock cycles before the expected edge, then the current per iod is shortened by one clock cycle. if the rxd event is between 2 and 3 clock cycles after the expected edge, then the current period is lengthened by one clock cycle. these intervals are considered to be drift and so corrective actions are automatically taken. manchester encoded data txd sfd data one bit start frame delimiter preamble length is set to 0 manchester encoded data txd sfd data command sync start frame delimiter manchester encoded data txd sfd data data sync start frame delimiter
574 6438fCatarmC21-jun-10 at91sam9g45 figure 33-11. bit resynchronization 33.7.3.4 asynchronous receiver if the usart is programmed in asynchronous operating mode (sync = 0), the receiver over- samples the rxd input line. the oversampling is either 16 or 8 times the baud rate clock, depending on the over bit in the mode register (us_mr). the receiver samples the rxd line. if the line is sampled during one half of a bit time at 0, a start bit is detected and data, parity and stop bits are successively sampled on the bit rate clock. if the oversampling is 16, (over at 0), a start is detected at the eighth sample at 0. then, data bits, parity bit and stop bit are sampled on each 16 sampling clock cycle. if the oversampling is 8 (over at 1), a start bit is detected at the fourth sample at 0. then, data bits, parity bit and stop bit are sampled on each 8 sampling clock cycle. the number of data bits, first bit sent and parity mode are selected by the same fields and bits as the transmitter, i.e. respectively chrl , mode9, msbf and par. for the synchronization mechanism only , the number of stop bits has no effect on the receiver as it considers only one stop bit, regardless of the field nbstop, so that resynchronization between the receiver and the transmitter can occur. moreover, as soon as the st op bit is sampled, the receiver starts looking for a new start bit so that resynchronization can also be accomplished when the transmitter is operating with one stop bit. figure 33-12 and figure 33-13 illustrate start detection and character reception when usart operates in asynchronous mode. rxd oversampling 16x clock sampling point expected edge tolerance synchro. jump sync jump synchro. error synchro. error
575 6438fCatarmC21-jun-10 at91sam9g45 figure 33-12. asynchronous start detection figure 33-13. asynchronous character reception 33.7.3.5 manchester decoder when the man field in us_mr register is set to 1, the manchester decoder is enabled. the decoder performs both preamble and start frame delimiter detection. one input line is dedicated to manchester encoded input data. an optional preamble sequence can be defined, it s length is user-defined and totally indepen- dent of the emitter side. use rx_pl in us_man register to configure the length of the preamble sequence. if the length is set to 0, no preamble is detected and the function is disabled. in addi- tion, the polarity of the input stream is programmable with rx_mpol field in us_man register. depending on the desired application the preamble pattern matching is to be defined via the rx_pp field in us_man. see figure 33-9 for available preamble patterns. unlike preamble, the start frame delimiter is shared between manchester encoder and decoder. so, if onebit field is set to 1, only a zero encoded manchester can be detected as a valid start frame delimiter. if onebit is set to 0, only a sync pattern is detected as a valid start frame delimiter. decoder operates by detecting transition on incoming stream. if rxd is sampled dur- ing one quarter of a bit time at zero, a start bit is detected. see figure 33-14 . the sample pulse rejection mechanism applies. sampling clock (x16) rxd start detection sampling baud rate clock rxd start rejection sampling 12345678 12345670 1234 12345678 9 10111213141516 d0 sampling d0 d1 d2 d3 d4 d5 d6 d7 rxd parity bit stop bit example: 8-bit, parity enabled baud rate clock start detection 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples
576 6438fCatarmC21-jun-10 at91sam9g45 figure 33-14. asynchronous star t bit detection the receiver is activated and starts preamble and frame delimiter detection, sampling the data at one quarter and then three quarters. if a valid preamble pattern or start frame delimiter is detected, the receiver continues decoding with the same synchronization. if the stream does not match a valid pattern or a valid start frame delimiter, the receiver re-synchronizes on the next valid edge.the minimum time threshold to estimate the bit value is three quarters of a bit time. if a valid preamble (if used) followed with a valid start frame delimiter is detected, the incoming stream is decoded into nrz data and passed to usart for processing. figure 33-15 illustrates manchester pattern mismatch. when incoming data stream is passed to the usart, the receiver is also able to detect manchester code vi olation. a code violation is a lack of transition in the middle of a bit cell. in this case, mane flag in us_csr register is raised. it is cleared by writing the control register (us_cr) with the rststa bit at 1. see figure 33-16 for an exam- ple of manchester error detection during data phase. figure 33-15. preamble pattern mismatch figure 33-16. manchester error flag when the start frame delimiter is a sync pattern (onebit field at 0), both command and data delimiter are supported. if a valid sync is detec ted, the received character is written as rxchr manchester encoded data txd 1234 sampling clock (16 x) start detection manchester encoded data txd sfd data preamble length is set to 8 preamble mismatch invalid pattern preamble mismatch manchester coding error manchester encoded data txd sfd preamble length is set to 4 elementary character bit time manchester coding error detected sampling points preamble subpacket and start frame delimiter were successfully decoded entering usart character area
577 6438fCatarmC21-jun-10 at91sam9g45 field in the us_rhr register and the rxsynh is updated. rxchr is set to 1 when the received character is a command, and it is set to 0 if the received character is a data. this mechanism alleviates and simplifies the direct memory access as the character contains its own sync field in the same register. as the decoder is setup to be used in unipolar mode, the first bit of the frame has to be a zero-to- one transition. 33.7.3.6 radio interface: manchester encoded usart application this section describes low data rate rf transm ission systems and their integration with a man- chester encoded usart. these systems are based on transmitter and receiver ics that support ask and fsk modulation schemes. the goal is to perform full duplex radio transmissi on of characters using two different frequency carriers. see the configuration in figure 33-17 . figure 33-17. manchester encoded characters rf transmission the usart module is configured as a manchester encoder/decoder. looking at the down- stream communication channel, manchester encoded characters are serially sent to the rf emitter. this may also include a user defined preamble and a start frame delimiter. mostly, pre- amble is used in the rf receiver to distinguish between a valid data from a transmitter and signals due to noise. the manchester stream is then modulated. see figure 33-18 for an exam- ple of ask modulation scheme. when a logic one is sent to the ask modulator, the power amplifier, referred to as pa, is enabled and transmits an rf signal at downstream frequency. when a logic zero is transmitted, the rf signal is turned off. if the fsk modulator is activated, two different frequencies are used to transmit dat a. when a logic 1 is sent, the modulator out- puts an rf signal at frequency f0 and switches to f1 if the data sent is a 0. see figure 33-19 . from the receiver side, another carrier frequency is used. the rf receiver performs a bit check operation examining demodulated data stream. if a valid pattern is detected, the receiver lna vco rf filter demod control bi-dir line pa rf filter mod vco control manchester decoder manchester encoder usart receiver usart emitter ask/fsk upstream receiver ask/fsk downstream transmitter upstream emitter downstream receiver serial configuration interface fup frequency carrier fdown frequency carrier
578 6438fCatarmC21-jun-10 at91sam9g45 switches to receiving mode. the demodulated stream is sent to the manchester decoder. because of bit checking inside rf ic, the data transferred to the microcontroller is reduced by a user-defined number of bits. the manchester preamble length is to be defined in accordance with the rf ic configuration. figure 33-18. ask modulator output figure 33-19. fsk modulator output 33.7.3.7 synchronous receiver in synchronous mode (sync = 1), the receiver samples the rxd signal on each rising edge of the baud rate clock. if a lo w level is detected, it is considered as a start. all data bits, the parity bit and the stop bits are sampled and the receiver waits for the next start bit. synchronous mode operations provide a high speed transfer capability. configuration fields and bits are the same as in asynchronous mode. figure 33-20 illustrates a character rec eption in synchronous mode. figure 33-20. synchronous mode character reception manchester encoded data default polarity unipolar output txd ask modulator output uptstream frequency f0 nrz stream 10 0 1 manchester encoded data default polarity unipolar output txd fsk modulator output uptstream frequencies [f0, f0+offset] nrz stream 10 0 1 d0 d1 d2 d3 d4 d5 d6 d7 rxd start sampling parity bit stop bit example: 8-bit, parity enabled 1 stop baud rate clock
579 6438fCatarmC21-jun-10 at91sam9g45 33.7.3.8 receiver operations when a character reception is completed, it is transferred to the receive holding register (us_rhr) and the rxrdy bit in the status regist er (us_csr) rises. if a character is com- pleted while the rxrdy is set, the ovre (ove rrun error) bit is set. the last character is transferred into us_rhr and overwrites the previous one. the ovre bit is cleared by writing the control register (us_cr) with the rststa (reset status) bit at 1. figure 33-21. receiver status d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit parity bit stop bit baud rate clock write us_cr rxrdy ovre d0 d1 d2 d3 d4 d5 d6 d7 start bit parity bit stop bit rststa = 1 read us_rhr
580 6438fCatarmC21-jun-10 at91sam9g45 33.7.3.9 parity the usart supports five parity modes selected by programming the par field in the mode register (us_mr). the par field also enables the multidrop mode, see multidrop mode on page 581 . even and odd parity bit generation and error detection are supported. if even parity is selected, the parity generator of the transmitter drives the parity bit at 0 if a num- ber of 1s in the character data bit is even, and at 1 if the number of 1s is odd. accordingly, the receiver parity checker counts the number of received 1s and reports a parity error if the sam- pled parity bit does not correspond. if odd parity is selected, the parity generator of the transmitter drives the parity bit at 1 if a number of 1s in the character data bit is even, and at 0 if the number of 1s is odd. accordingly, the receiver parity checker counts the number of received 1s and reports a parity error if the sampled parity bit does not correspond. if the mark parity is used, the parity generator of the transmitter drives the parity bit at 1 for all characters. the receiver parity checker reports an error if the parity bit is sampled at 0. if the space parity is used, the parity generator of the transmitter drives the parity bit at 0 for all characters. the receiver parity checker reports an error if the parity bit is sampled at 1. if parity is disabled, the transmitter does not generate any parity bit and the receiver does not report any parity error. table 33-9 shows an example of the parity bit for the character 0x41 (character ascii a) depending on the configuration of the usart. because there are two bits at 1, 1 bit is added when a parity is odd, or 0 is added when a parity is even. when the receiver detects a parity error, it sets the pare (parity error) bit in the channel status register (us_csr). the pare bit can be cleared by writing the control register (us_cr) with the rststa bit at 1. figure 33-22 illustrates the parity bit status setting and clearing. table 33-9. parity bit examples character hexa binary parity bit parity mode a 0x41 0100 0001 1 odd a 0x41 0100 0001 0 even a 0x41 0100 0001 1 mark a 0x41 0100 0001 0 space a 0x41 0100 0001 none none
581 6438fCatarmC21-jun-10 at91sam9g45 figure 33-22. parity error 33.7.3.10 multidrop mode if the par field in the mode register (us_mr) is programmed to the value 0x6 or 0x07, the usart runs in multidrop mode. this mode differentiates the data characters and the address characters. data is transmitted with the parity bit at 0 and addresses are transmitted with the parity bit at 1. if the usart is configured in multidrop mode, the receiver sets the pare parity error bit when the parity bit is high and the transmitter is able to send a character with the parity bit high when the control register is written with the senda bit at 1. to handle parity error, the pare bit is cleared when the control register is written with the bit rststa at 1. the transmitter sends an address byte (parity bit set) when senda is written to us_cr. in this case, the next byte written to us_thr is trans mitted as an address. any character written in us_thr without having written the command senda is transmitted normally with the parity at 0. 33.7.3.11 transmitter timeguard the timeguard feature enables the usar t interface with slow remote devices. the timeguard function enables the transmitter to insert an idle state on the txd line between two characters. this idle state actually acts as a long stop bit. the duration of the idle state is programmed in the tg field of the transmitter timeguard regis- ter (us_ttgr). when this field is programmed at zero no timeguard is generated. otherwise, the transmitter holds a high level on txd after each transmitted byte during the number of bit periods programmed in tg in addition to the number of stop bits. as illustrated in figure 33-23 , the behavior of txrdy and txempty status bits is modified by the programming of a timeguard. txrdy rises only when the start bit of the next character is sent, and thus remains at 0 during the timeguard transmission if a character has been written in us_thr. txempty remains low until the timeguard transmission is completed as the time- guard is part of the current character being transmitted. d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit bad parity bit stop bit baud rate clock write us_cr pare rxrdy rststa = 1
582 6438fCatarmC21-jun-10 at91sam9g45 figure 33-23. timeguard operations table 33-10 indicates the maximum length of a timeguard period that the transmitter can handle in relation to the function of the baud rate. 33.7.3.12 receiver time-out the receiver time-out provides support in handling variable-length frames. this feature detects an idle condition on the rxd line. when a time-out is detected, the bit timeout in the channel status register (us_csr) rises and can generate an interrupt, thus indicating to the driver an end of frame. the time-out delay period (during which the receiver waits for a new character) is programmed in the to field of the receiver time-out regist er (us_rtor). if the to field is programmed at 0, the receiver time-out is disabled and no time-out is detected. the timeout bit in us_csr remains at 0. otherwise, the receiver loads a 16-bit counter with the value programmed in to. this counter is decremented at each bit per iod and reloaded each time a new character is received. if the counter reaches 0, the timeout bit in the status register rises. then, the user can either: ? stop the counter clock until a new character is received. this is performed by writing the control register (us_cr) with the sttto (start time-out) bit at 1. in this case, the idle state d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock start bit tg = 4 write us_thr d0 d1 d2 d3 d4 d5 d6 d7 parity bit stop bit txrdy txempty tg = 4 table 33-10. maximum timeguard length depending on baud rate baud rate bit time timeguard bit/sec s ms 1 200 833 212.50 9 600 104 26.56 14400 69.4 17.71 19200 52.1 13.28 28800 34.7 8.85 33400 29.9 7.63 56000 17.9 4.55 57600 17.4 4.43 115200 8.7 2.21
583 6438fCatarmC21-jun-10 at91sam9g45 on rxd before a new character is received will not provide a time-out. this prevents having to handle an interrupt before a character is received and allows waiting for the next idle state on rxd after a frame is received. ? obtain an interrupt while no character is rece ived. this is performed by writing us_cr with the retto (reload and start time-out) bit at 1. if retto is performed, the counter starts counting down immediately from the value to. this enables generation of a periodic interrupt so that a user time-out can be handled, for example when no key is pressed on a keyboard. if sttto is performed, the counter clock is stopped until a first character is received. the idle state on rxd before the start of the frame does not provide a time-out. this prevents having to obtain a periodic interrupt and enables a wait of the end of frame when the idle state on rxd is detected. if retto is performed, the counter starts counting down immediately from the value to. this enables generation of a periodic interrupt so t hat a user time-out can be handled, for example when no key is pressed on a keyboard. figure 33-24 shows the block diagram of the receiver time-out feature. figure 33-24. receiver time-out block diagram table 33-11 gives the maximum time-out period for some standard baud rates. 16-bit time-out counter 0 to timeout baud rate clock = character received retto load clock 16-bit value sttto dq 1 clear table 33-11. maximum time-out period baud rate bit time time-out bit/sec s ms 600 1 667 109 225 1 200 833 54 613 2 400 417 27 306 4 800 208 13 653 9 600 104 6 827 14400 69 4 551 19200 52 3 413 28800 35 2 276 33400 30 1 962
584 6438fCatarmC21-jun-10 at91sam9g45 33.7.3.13 framing error the receiver is capable of detecting framing errors. a framing error happens when the stop bit of a received character is detected at level 0. this can occur if the receiver and the transmitter are fully desynchronized. a framing error is reported on the frame bit of the channel status register (us_csr). the frame bit is asserted in the middle of the stop bit as soon as the framing error is detected. it is cleared by writing the control register (us_cr) with the rststa bit at 1. figure 33-25. framing error status 33.7.3.14 transmit break the user can request the transmitter to generate a break condition on the txd line. a break con- dition drives the txd line low during at least one complete character. it appears the same as a 0x00 character sent with the parity and the stop bits at 0. however, the transmitter holds the txd line at least during one character until the user requests the break condition to be removed. a break is transmitted by writing the control register (us_cr) with the sttbrk bit at 1. this can be performed at any time, either while the transmitter is empty (no character in either the shift register or in us_thr) or when a character is being transmitted. if a break is requested while a character is being shifted out, the charac ter is first completed before the txd line is held low. once sttbrk command is requested further sttbrk commands are ignored until the end of the break is completed. the break condition is removed by writing us_cr with the stpbrk bit at 1. if the stpbrk is requested before the end of the minimum break duration (one character, including start, data, parity and stop bits), the transmitter ensures that the break condition completes. 56000 18 1 170 57600 17 1 138 200000 5 328 table 33-11. maximum time-out period (continued) baud rate bit time time-out d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit parity bit stop bit baud rate clock write us_cr frame rxrdy rststa = 1
585 6438fCatarmC21-jun-10 at91sam9g45 the transmitter considers the break as though it is a character, i.e. the sttbrk and stpbrk commands are taken into account only if the txrdy bit in us_csr is at 1 and the start of the break condition clears the txrdy and txempty bits as if a character is processed. writing us_cr with the both sttbrk and stpb rk bits at 1 can lead to an unpredictable result. all stpbrk commands requested without a previous sttbrk command are ignored. a byte written into the transmit holding register while a break is pending, but not started, is ignored. after the break condition, the transmitter returns the txd line to 1 for a minimum of 12 bit times. thus, the transmitter ensures that the remote receiver detects correctly the end of break and the start of the next character. if the timeguard is programmed with a value higher than 12, the txd line is held high for the timeguard period. after holding the txd line for this period, the transmitter resumes normal operations. figure 33-26 illustrates the effect of both the start break (sttbrk ) and stop break (stpbrk) commands on the txd line. figure 33-26. break transmission 33.7.3.15 receive break the receiver detects a break condition when all data, parity and stop bits are low. this corre- sponds to detecting a framing error with data at 0x00, but frame remains low. when the low stop bit is detected, the receiver asserts the rxbrk bit in us_csr. this bit may be cleared by writing the control regi ster (us_cr) with the bit rststa at 1. an end of receive break is detected by a high leve l for at least 2/16 of a bit period in asynchro- nous operating mode or one sample at high level in synchronous operating mode. the end of break detection also asserts the rxbrk bit. 33.7.3.16 hardware handshaking the usart features a hardware handshaking out-of-band flow control. the rts and cts pins are used to connect with the remote device, as shown in figure 33-27 . d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock write us_cr txrdy txempty stpbrk = 1 sttbrk = 1 break transmission end of break
586 6438fCatarmC21-jun-10 at91sam9g45 figure 33-27. connection with a remote device for hardware handshaking setting the usart to operate with hardware handshaking is performed by writing the usart_mode field in the mode register (us_mr) to the value 0x2. the usart behavior when hardware handshaking is enabled is the same as the behavior in standard synchronous or asynchronous mode, except that the receiver drives the rts pin as described below and the level on the cts pin modifies the behavior of the transmitter as described below. using this mode requires usin g the pdc channel for reception. the transmitter can handle hardware handshaking in any case. figure 33-28 shows how the receiver operates if hardware handshaking is enabled. the rts pin is driven high if the receiver is disabled and if the status rxbuff (receive buffer full) com- ing from the pdc channel is high. normally, the remote device does not start transmitting while its cts pin (driven by rts) is high. as soon as the receiver is enabled , the rts falls, indicating to the remote device that it can start transmitt ing. defining a new buffer to the pdc clears the status bit rxbuff and, as a result, asserts the pin rts low. figure 33-28. receiver behavior when operating with hardware handshaking figure 33-29 shows how the transmitter operates if hardware handshaking is enabled. the cts pin disables the transmitt er. if a character is being processi ng, the transmitter is disabled only after the completion of the current character and transmission of the next character happens as soon as the pin cts falls. figure 33-29. transmitter behavior when operating with hardware handshaking usart txd cts remote device rxd txd rxd rts rts cts rts rxbuff write us_cr rxen = 1 rxd rxdis = 1 cts txd
587 6438fCatarmC21-jun-10 at91sam9g45 33.7.4 iso7816 mode the usart features an iso7816-compatible operating mode. this mode permits interfacing with smart cards and security access modules (sam) communicating through an iso7816 link. both t = 0 and t = 1 protocols defined by the iso7816 specification are supported. setting the usart in iso7816 mode is performed by writing the usart_mode field in the mode register (us_mr) to the value 0x4 for protoc ol t = 0 and to the value 0x5 for protocol t = 1. 33.7.4.1 iso7816 mode overview the iso7816 is a half duplex communication on only one bidirectional line. the baud rate is determined by a division of the clo ck provided to the remote device (see baud rate generator on page 566 ). the usart connects to a smart card as shown in figure 33-30 . the txd line becomes bidirec- tional and the baud rate generator feeds the iso7816 clock on the sck pin. as the txd pin becomes bidirectional, its output remains driven by the output of the transmitter but only when the transmitter is active while its input is direct ed to the input of the receiver. the usart is con- sidered as the master of the communication as it generates the clock. figure 33-30. connection of a smart card to the usart when operating in iso7816, either in t = 0 or t = 1 modes, the character format is fixed. the configuration is 8 data bits, ev en parity and 1 or 2 stop bits, regardless of the values pro- grammed in the chrl, mode9, par and chmode fields. msbf can be used to transmit lsb or msb first. parity bit (par) can be used to transmit in normal or inverse mode. refer to usart mode register on page 623 and par: parity type on page 624 . the usart cannot operate concurrently in both receiver and transmitter modes as the commu- nication is unidirectional at a time. it has to be configured according to the required mode by enabling or disabling either the receiver or the transmitter as desired. enabling both the receiver and the transmitter at the same time in iso7816 mode may lead to unpredictable results. the iso7816 specification defines an inverse transmission format. data bits of the character must be transmitted on the i/o line at their negative value. the usart does not support this for- mat and the user has to perform an exclusive or on the data before writing it in the transmit holding register (us_thr) or after reading it in the receive holding register (us_rhr). 33.7.4.2 protocol t = 0 in t = 0 protocol, a character is made up of one start bit, eight data bits, one parity bit and one guard time, which lasts two bit times. the transmitter shifts out the bits and does not drive the i/o line during the guard time. if no parity error is detected, the i/o line remains at 1 during the guard time and the transmitter can continue with the transmission of the next character, as shown in figure 33-31 . smart card sck clk txd i/o usart
588 6438fCatarmC21-jun-10 at91sam9g45 if a parity error is detected by the receiver, it drives the i/o line at 0 during the guard time, as shown in figure 33-32 . this error bit is also named nack, for non acknowledge. in this case, the character lasts 1 bit time more, as the guard time length is the same and is added to the error bit time which lasts 1 bit time. when the usart is the receiver and it detects an error, it does not load the erroneous character in the receive holding register (us_rhr). it appropriately sets the pare bit in the status reg- ister (us_sr) so that the software can handle the error. figure 33-31. t = 0 protocol without parity error figure 33-32. t = 0 protocol with parity error 33.7.4.3 receive error counter the usart receiver also records the total number of errors. this can be read in the number of error (us_ner) register. the nb_errors field can record up to 255 errors. reading us_ner automatically clears the nb_errors field. 33.7.4.4 receive nack inhibit the usart can also be configured to inhibit an error. this can be achieved by setting the inack bit in the mode register (us_mr). if inack is at 1, no error signal is driven on the i/o line even if a parity bit is detected, but the inac k bit is set in the status register (us_sr). the inack bit can be cleared by writing the control register (us_cr) with the rstnack bit at 1. moreover, if inack is set, the erroneous receiv ed character is stored in the receive holding register, as if no error occurred. however, the rxrdy bit does not raise. 33.7.4.5 transmit character repetition when the usart is transmitting a character and gets a nack, it can automatically repeat the character before moving on to the next one. repetition is enabled by writing the max_iteration field in the mode register (us_mr) at a value higher than 0. each character can be transmitted up to eight times; the first transmission plus seven repetitions. if max_iteration does not equal zero, the u sart repeats the character as many times as the value loaded in max_iteration. d0 d1 d2 d3 d4 d5 d6 d7 rxd parity bit baud rate clock start bit guard time 1 next start bit guard time 2 d0 d1 d2 d3 d4 d5 d6 d7 i/o parity bit baud rate clock start bit guard time 1 start bit guard time 2 d0 d1 error repetition
589 6438fCatarmC21-jun-10 at91sam9g45 when the usart repetition number reaches max_iteration, the iteration bit is set in the channel status register (us_csr). if the repetition of the character is acknowledged by the receiver, the repetitions are stopped and the iteration counter is cleared. the iteration bit in us_csr can be cleared by writing the control register with the rsit bit at 1. 33.7.4.6 disable successive receive nack the receiver can limit the number of successive nacks sent back to the remote transmitter. this is programmed by setting the bit dsnack in the mode register (us_mr). the maximum number of nack transmitted is programmed in the max_iteration field. as soon as max_iteration is reached, the character is cons idered as correct, an acknowledge is sent on the line and the iteration bit in the channel status register is set. 33.7.4.7 protocol t = 1 when operating in iso7816 protocol t = 1, the transmission is similar to an asynchronous for- mat with only one stop bit. the parity is generated when transmitting and checked when receiving. parity error detection sets the pare bit in the channel status register (us_csr). 33.7.5 irda mode the usart features an irda mode supplying half-duplex point-to-point wireless communica- tion. it embeds the modulator and demodulator which allows a glueless connection to the infrared transceivers, as shown in figure 33-33 . the modulator and demodulator are compliant with the irda specification version 1.1 and support data transfer speeds ranging from 2.4 kb/s to 115.2 kb/s. the usart irda mode is enabled by setting t he usart_mode field in the mode register (us_mr) to the value 0x8. the irda filter register (us_if) allows configuring the demodulator filter. the usart transmitter and receiver operate in a normal asynchronous mode and all parameters are accessible. note that the modulator and the demodulator are activated. figure 33-33. connection to irda transceivers the receiver and the transmitter must be enabled or disabled according to the direction of the transmission to be managed. to receive irda signals, the following needs to be done: ? disable tx and enable rx irda transceivers rxd rx txd tx usart demodulator modulator receiver transmitter
590 6438fCatarmC21-jun-10 at91sam9g45 ? configure the txd pin as pio and set it as an output at 0 (to avoid led emission). disable the internal pull-up (better for power consumption). ? receive data 33.7.5.1 irda modulation for baud rates up to and including 115.2 kbits/sec, the rzi modulation scheme is used. 0 is represented by a light pulse of 3/16th of a bit time. some examples of signal pulse duration are shown in table 33-12 . figure 33-34 shows an example of character transmission. figure 33-34. irda modulation 33.7.5.2 irda baud rate table 33-13 gives some examples of cd values, baud rate error and pulse duration. note that the requirement on the maximum acceptable error of 1.87% must be met. table 33-12. irda pulse duration baud rate pulse duration (3/16) 2.4 kb/s 78.13 s 9.6 kb/s 19.53 s 19.2 kb/s 9.77 s 38.4 kb/s 4.88 s 57.6 kb/s 3.26 s 115.2 kb/s 1.63 s bit period bit period 3 16 start bit data bits stop bit 0 0 0 0 0 1 1 1 1 1 transmitter output txd table 33-13. irda baud rate error peripheral clock baud rate cd baud rate error pulse time 3 686 400 115 200 2 0.00% 1.63 20 000 000 115 200 11 1.38% 1.63 32 768 000 115 200 18 1.25% 1.63 40 000 000 115 200 22 1.38% 1.63 3 686 400 57 600 4 0.00% 3.26 20 000 000 57 600 22 1.38% 3.26 32 768 000 57 600 36 1.25% 3.26
591 6438fCatarmC21-jun-10 at91sam9g45 33.7.5.3 irda demodulator the demodulator is based on the irda receive filter co mprised of an 8-bit down counter which is loaded with the value programmed in us_if. when a falling edge is detected on the rxd pin, the filter counter starts counting down at the master clock (mck) speed. if a rising edge is detected on the rxd pin, the counter stops and is reloaded with us_if. if no rising edge is detected when the counter reaches 0, the input of the receiver is driven low during one bit time. figure 33-35 illustrates the operations of the irda demodulator. figure 33-35. irda demodulator operations as the irda mode uses the same logic as the iso7816, note that the fi_di_ratio field in us_fidi must be set to a value higher than 0 in order to assure irda communications operate correctly. 40 000 000 57 600 43 0.93% 3.26 3 686 400 38 400 6 0.00% 4.88 20 000 000 38 400 33 1.38% 4.88 32 768 000 38 400 53 0.63% 4.88 40 000 000 38 400 65 0.16% 4.88 3 686 400 19 200 12 0.00% 9.77 20 000 000 19 200 65 0.16% 9.77 32 768 000 19 200 107 0.31% 9.77 40 000 000 19 200 130 0.16% 9.77 3 686 400 9 600 24 0.00% 19.53 20 000 000 9 600 130 0.16% 19.53 32 768 000 9 600 213 0.16% 19.53 40 000 000 9 600 260 0.16% 19.53 3 686 400 2 400 96 0.00% 78.13 20 000 000 2 400 521 0.03% 78.13 32 768 000 2 400 853 0.04% 78.13 table 33-13. irda baud rate error (continued) peripheral clock baud rate cd baud rate error pulse time mck rxd receiver input pulse rejected 65432 6 1 65432 0 pulse accepted counter value
592 6438fCatarmC21-jun-10 at91sam9g45 33.7.6 rs485 mode the usart features the rs485 mode to enable li ne driver control. while operating in rs485 mode, the usart behaves as though in asynch ronous or synchronous mode and configuration of all the parameters is possible. the differenc e is that the rts pin is driven high when the transmitter is operating. the behavior of the rts pin is controlled by the txempty bit. a typical connection of the usart to a rs485 bus is shown in figure 33-36 . figure 33-36. typical connection to a rs485 bus the usart is set in rs485 mode by programming the usart_mode field in the mode regis- ter (us_mr) to the value 0x1. the rts pin is at a level inverse to the txempt y bit. significantly, the rts pin remains high when a timeguard is programmed so that the line can remain driven after the last character com- pletion. figure 33-37 gives an example of the rts waveform during a character transmission when the timeguard is enabled. figure 33-37. example of rts drive with timeguard 33.7.7 spi mode the serial peripheral interface (spi) mode is a synchronous serial data link that provides com- munication with external devices in master or slave mode. it also enables communication between processors if an external processor is connected to the system. usart rts txd rxd differential bus d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock tg = 4 write us_thr txrdy txempty rts
593 6438fCatarmC21-jun-10 at91sam9g45 the serial peripheral interface is essentially a shift register that serially transmits data bits to other spis. during a data transfer, one spi system acts as the master which controls the data flow, while the other devices act as slaves'' whic h have data shifted into and out by the master. different cpus can take turns being masters and one master may simultaneously shift data into multiple slaves. (multiple master protocol is the opposite of single master protocol, where one cpu is always the master while all of the others are always slaves.) however, only one slave may drive its output to write data back to the master at any given time. a slave device is selected when its nss signal is asserted by the master. the usart in spi master mode can address only one spi slave because it can generate only one nss signal. the spi system consists of two data lines and two control lines: ? master out slave in (mosi): this data line supplies the output data from the master shifted into the input of the slave. ? master in slave out (miso): this data line supplies the output data from a slave to the input of the master. ? serial clock (sck): this control line is driven by the master and regulates the flow of the data bits. the master may transmit data at a variety of baud rates. the sck line cycles once for each bit that is transmitted. ? slave select (nss): this control line allows the master to select or deselect the slave. 33.7.7.1 modes of operation the usart can operate in spi master mode or in spi slave mode. operation in spi master mode is programmed by writing at 0xe the usart_mode field in the mode register. in this case the spi lines must be connected as described below: ? the mosi line is driven by the output pin txd ? the miso line drives the input pin rxd ? the sck line is driven by the output pin sck ? the nss line is driven by the output pin rts operation in spi slave mode is programmed by writing at 0xf the usart_mode field in the mode register. in this case the spi lines must be connected as described below: ? the mosi line drives the input pin rxd ? the miso line is driven by the output pin txd ? the sck line drives the input pin sck ? the nss line drives the input pin cts in order to avoid unpredicted behavior, any change of the spi mode must be followed by a soft- ware reset of the transmitter and of the receiver (except the initial configuration after a hardware reset). (see section 33.7.8.2 ). 33.7.7.2 baud rate in spi mode, the baudrate generator operates in the same way as in usart synchronous mode: see baud rate in synchronous mode or spi mode on page 568. however, there are some restrictions: in spi master mode:
594 6438fCatarmC21-jun-10 at91sam9g45 ? the external clock sck must not be selected (usclks 0x3), and the bit clko must be set to 1 in the mode register (us_mr), in order to generate correctly the serial clock on the sck pin. ? to obtain correct behavior of the receiver and the transmitter, the value programmed in cd of must be superior or equal to 4. ? if the internal clock divided (mck/div) is selected, the value programmed in cd must be even to ensure a 50:50 mark/space ratio on the sck pin, this value can be odd if the internal clock is selected (mck). in spi slave mode: ? the external clock (sck) selection is forced regardless of the value of the usclks field in the mode register (us_mr). likewise, the value written in us_brgr has no effect, because the clock is provided directly by the signal on the usart sck pin. ? to obtain correct behavior of the receiver and the transmitter, the external clock (sck) frequency must be at least 4 times lower than the system clock.
595 6438fCatarmC21-jun-10 at91sam9g45 33.7.7.3 data transfer up to 9 data bits are successively shifted out on the txd pin at each rising or falling edge (depending of cpol and cpha) of the programmed serial clock. there is no start bit, no parity bit and no stop bit. the number of data bits is selected by the chrl field and the mode 9 bit in the mode register (us_mr). the 9 bits are selected by setting the mode 9 bit regardless of the chrl field. the msb data bit is always sent first in spi mode (master or slave). four combinations of polarity and phase are available for data transfers. the clock polarity is programmed with the cpol bit in the mode regi ster. the clock phase is programmed with the cpha bit. these two parameters determine the edges of the clock signal upon which data is driven and sampled. each of the two parameters has two possible states, resulting in four possi- ble combinations that are incompatible with one another. thus, a master/slave pair must use the same parameter pair values to communicate. if multiple slaves are used and fixed in different configurations, the master must reconfigure itself each time it needs to communicate with a dif- ferent slave. table 33-14. spi bus protocol mode spi bus protocol mode cpol cpha 001 100 211 310
596 6438fCatarmC21-jun-10 at91sam9g45 figure 33-38. spi transfer format (cpha=1, 8 bits per transfer) figure 33-39. spi transfer format (cpha=0, 8 bits per transfer) 33.7.7.4 receiver and transmitter control see receiver and transmitter control on page 570. 6 sck (cpol = 0) sck (cpol = 1) mosi spi master ->txd spi slave -> rxd nss spi master -> rts spi slave -> cts sck cycle (for reference) msb msb lsb lsb 6 6 5 5 4 4 3 3 2 2 1 1 1 2345 78 6 miso spi master ->rxd spi slave -> txd sck (cpol = 0) sck (cpol = 1) 1 2345 7 mosi spi master -> txd spi slave -> rxd miso spi master -> rxd spi slave -> txd nss spi master -> rts spi slave -> cts sck cycle (for reference) 8 msb msb lsb lsb 6 6 5 5 4 4 3 3 1 1 2 2 6
597 6438fCatarmC21-jun-10 at91sam9g45 33.7.7.5 character transmission the characters are sent by writing in the tr ansmit holding register (us_thr). the transmitter reports two status bits in the channel status register (us_csr): txrdy (transmitter ready), which indicates that us_thr is empty and txempty, which indicates that all the characters written in us_thr have been processed. when the current character processing is completed, the last character written in us_thr is transferred into the shift register of the transmitter and us_thr becomes empty, thus txrdy rises. both txrdy and txempty bits are low when the transmitter is disabled. writing a character in us_thr while txrdy is low has no effect and the written character is lost. if the usart is in spi slave mode and if a character must be sent while the transmit holding register (us_thr) is empty, the unre (underru n error) bit is set. the txd transmission line stays at high level during all th is time. the unre bit is cleared by writing the control register (us_cr) with the rststa (reset status) bit at 1. in spi master mode, the slave select line (nss) is asserted at low level 1 tbit before the trans- mission of the msb bit and released at high level 1 tbit after the transmission of the lsb bit. so, the slave select line (nss) is always released be tween each character transmission and a mini- mum delay of 3 tbits always inserted. however, in order to address slave devices supporting the csaat mode (chip select active after transfer), the slave select line (nss) can be forced at low level by writing the control register (us_cr) with the rtsen bit at 1. the slave select line (nss) can be released at high level only by writing the control register (us_cr) with the rts- dis bit at 1 (for example, when all data have been transferred to the slave device). in spi slave mode, the transmitter does not require a falling edge of the slave select line (nss) to initiate a character transmission but only a low level. however, this lo w level must be present on the slave select line (nss) at least 1 tbit before the first serial clock cycle corresponding to the msb bit. 33.7.7.6 character reception when a character reception is completed, it is transferred to the receive holding register (us_rhr) and the rxrdy bit in the status regist er (us_csr) rises. if a character is com- pleted while rxrdy is set, the ovre (overrun erro r) bit is set. the last character is transferred into us_rhr and overwrites the pr evious one. the ovre bit is cleared by writing the control register (us_cr) with the rststa (reset status) bit at 1. to ensure correct behavior of the receiver in spi slave mode, the master device sending the frame must ensure a minimum delay of 1 tb it between each character transmission. the receiver does not require a falling edge of the slave select line (nss) to initiate a character reception but only a low level. however, this low level must be present on the slave select line (nss) at least 1 tbit before the first serial clock cycle corresponding to the msb bit. 33.7.7.7 receiver timeout because the receiver baudrate clock is active only during data transfers in spi mode, a receiver timeout is impossible in this mode, whatever the time-out value is (field to) in the time-out register (us_rtor).
598 6438fCatarmC21-jun-10 at91sam9g45 33.7.8 lin mode the lin mode provides master node and slave node connectivity on a lin bus. the lin (local interconnect network) is a serial communication protocol which efficiently sup- ports the control of mechatronic nodes in distributed automotive applications. the main properties of the lin bus are: ? single master/multiple slaves concept ? low cost silicon implementation based on common uart/sci interface hardware, an equivalent in software, or as a pure state machine. ? self synchronization without quartz or ceramic resonator in the slave nodes ? deterministic signal transmission ? low cost single-wire implementation ? speed up to 20 kbit/s lin provides cost efficient bu s communication where the bandwid th and versatility of can are not required. the lin mode enables processing lin frames with a minimum of action from the microprocessor. 33.7.8.1 modes of operation the usart can act either as a lin master node or as a lin slave node. the node configuration is chosen by setting t he usart_mode field in the usart3 mode reg- ister (us_mr): ? lin master node (usart_mode=0xa) ? lin slave node (usart_mode=0xb) in order to avoid unpredicted behavior, any change of the lin node configuration must be fol- lowed by a software reset of the transmitter and of the receiver (except the initial node configuration after a hardware reset). (see section 33.7.8.2 ) 33.7.8.2 receiver and transmitter control see receiver and transmitter control on page 570. 33.7.8.3 character transmission see transmitter operations on page 570. 33.7.8.4 character reception see receiver operations on page 579.
599 6438fCatarmC21-jun-10 at91sam9g45 33.7.8.5 header transmission (master node configuration) all the lin frames start with a header which is sent by the master node and consists of a synch break field, synch field and identifier field. so in master node configuration, the frame handling starts with the sending of the header. the header is transmitted as soon as the identifier is written in the lin identifier register (us_linir). at this moment the flag txrdy falls. the break field, the synch field and the identif ier field are sent automatically one after the other. the break field consists of 13 dominant bits a nd 1 recessive bit, the synch field is the charac- ter 0x55 and the identifier corresponds to the character written in the lin identifier register (us_linir). the identifier parity bits c an be automatically computed and sent (see section 33.7.8.8 ). the flag txrdy rises when the identifier character is transferred into the shift register of the transmitter.as soon as the synch break field is transmitted, the flag linbk in the channel sta- tus register (us_csr) is set to 1. likewise, as soon as the identifier field is sent, the flag linid in the channel status register (us_csr) is set to 1. these flags are reset by writing the bit rststa at 1 in the control register (us_cr). figure 33-40. header transmission txd baud rate clock start bit write us_linir 10101010 txrdy stop bit start bit id0 id1 id2 id3 id4 id5 id6 id7 break field 13 dominant bits (at 0) stop bit break delimiter 1 recessive bit (at 1) synch byte = 0x55 us_linir id linid in us_csr linbk in us_csr write rststa=1 in us_cr
600 6438fCatarmC21-jun-10 at91sam9g45 33.7.8.6 header reception (slave node configuration) all the lin frames start with a header which is sent by the master node and consists of a synch break field, synch field and identifier field. in slave node configuration, the frame handling starts with the reception of the header. the usart uses a break detection threshold of 11 nominal bit times at the actual baud rate. at any time, if 11 consecutive rece ssive bits are detected on the bus, the usart detects a break field. as long as a break field has not been detected, the usart stays idle and the received data are not taken in account. when a break field has been detected, the flag linbk in the channel status register (us_csr) is set to 1 and the usart expects th e synch field character to be 0x55. this field is used to update the actual baud rate in order to stay synchronized (see section 33.7.8.7 ). if the received synch character is not 0x55, an inc onsistent synch field error is generated (see sec- tion 33.7.8.13 ). after receiving the synch field, the usart expects to receive the identifier field. when the identifier field has been received, the flag linid in the channel status register (us_csr) is set to 1. at this moment the field idchr in the lin identifier register (us_linir) is updated with the received character. the iden tifier parity bits can be automatically computed and checked (see section 33.7.8.8 ).the flags linid and linbk are reset by writing the bit rst- sta at 1 in the control register (us_cr). figure 33-41. header reception rxd baud rate clock te rststa=1 in us_cr linid us_linir linbk start bit 10101010 stop bit start bit id0 id1 id2 id3 id4 id5 id6 id7 break field 13 dominant bits (at 0) stop bit break delimiter 1 recessive bit (at 1) synch byte = 0x55
601 6438fCatarmC21-jun-10 at91sam9g45 33.7.8.7 slave node synchronization the synchronization is done only in slave node configuration. the procedure is based on time measurement between fallin g edges of the synch field. the falling edges are available in dis- tances of 2, 4, 6 and 8 bit times. figure 33-42. synch field the time measurement is made by a 19-bit counter clocked by the sampling clock (see section 33.7.1 ). when the start bit of the synch field is detected the counter is reset. then during the next 8 tbits of the synch field, the counter is increm ented. at the end of these 8 tbits, the counter is stopped. at this moment, the 16 most significant bi ts of the counter (value divided by 8) gives the new clock divider (cd) and the 3 least significant bits of this value (the remainder) gives the new fractional part (fp). when the synch field has been re ceived, the clock divider (cd) and the fractional part (fp) are updated in the baud rate generator register (us_brgr). figure 33-43. slave node synchronization the accuracy of the synchronization depends on several parameters: ? the nominal clock frequency (f nom ) (the theoretical slave node clock frequency) ? the baudrate ? the oversampling (over=0 => 16x or over=0 => 8x) the following formula is used to compute the deviation of the slave bit rate relative to the master bit rate after synchronization (f slave is the real slave node clock frequency). start bit stop bit synch field 8 tbit 2 tbit 2 tbit 2 tbit 2 tbit rxd baud rate clock linidrx synchro counter 000_0011_0001_0110_1101 us_brgr clcok divider (cd) 0000_0110_0010_1101 us_brgr fractional part (fp) 101 initial cd initial fp reset start bit 10101010 stop bit start bit id0 id1 id2 id3 id4 id5 id6 id7 break field 13 dominant bits (at 0) stop bit break delimiter 1 recessive bit (at 1) synch byte = 0x55
602 6438fCatarmC21-jun-10 at91sam9g45 f tol_unsynch is the deviation of the real slave node clock from the nominal clock frequency. the lin standard imposes that it must not exceed 15%. the lin standard imposes also that for communication between two nodes, their bit rate must not differ by more than 2%. this means that the baudrate_deviation must not exceed 1%. it follows from that, a minimum value for the nominal clock frequency: examples: ? baudrate = 20 kbit/s, over=0 (oversampling 16x) => f nom (min) = 2.64 mhz ? baudrate = 20 kbit/s, over=1 (oversampling 8x) => f nom (min) = 1.47 mhz ? baudrate = 1 kbit/s, over=0 (oversampling 16x) => f nom (min) = 132 khz ? baudrate = 1 kbit/s, over=1 (oversampling 8x) => f nom (min) = 74 khz if the fractional baud rate is not used, the accuracy of the synchronization becomes much lower. when the counter is stopped, the 16 most significant bits of the counter (value divided by 8) gives the new clock divider (cd) . this value is rounded by adding th e first insignificant bit. the equation of the baudrate deviation is the same as given above, but the constants are as follows: it follows from that, a minimum value for the nominal clock frequency: examples: ? baudrate = 20 kbit/s, over=0 (oversampling 16x) => f nom (min) = 19.12 mhz ? baudrate = 20 kbit/s, over=1 (oversampling 8x) => f nom (min) = 9.71 mhz ? baudrate = 1 kbit/s, over=0 (oversampling 16x) => f nom (min) = 956 khz ? baudrate = 1 kbit/s, over=1 (oversampling 8x) => f nom (min) = 485 khz 33.7.8.8 identifier parity a protected identifier consists of two sub-fields; the identifier and the identifier parity. bits 0 to 5 are assigned to the identifier and bits 6 and 7 are assigned to the parity. baudrate_deviation 100 [ 82over ? () + ] baudrate 8f slave -------------------------------------------------------------------------------------------- - ?? ?? % = baudrate_deviation 100 [ 82over ? () + ] baudrate 8 f tol_unsynch 100 --------------------------------------- ?? ?? xf nom -------------------------------------------------------------------------------------------- - ?? ?? ?? ?? ?? % = 0.5 ? +0.5 -1 +1 << ? () 100 0.5 8 2 over ? () 1 + [] baudrate 8 15 ? 100 --------- - 1 + ?? ?? 1% ------------------------------------------------------------------------------------------------ ?? ?? ?? ?? ?? hz = 4 ? +4 -1 +1 << ? () ? () 1 + [] baudrate 8 15 ? 100 --------- - 1 + ?? ?? 1% ------------------------------------------------------------------------------------------- ?? ?? ?? ?? ?? hz =
603 6438fCatarmC21-jun-10 at91sam9g45 the usart interface can generate/check these parity bits, but this feature can also be disabled. the user can choose between two modes by the pardis bit of the lin mode register (us_linmr): ? pardis = 0: during header transmission, the parity bits are computed and sent with the 6 least significant bits of the idchr field of the lin identifier register (us_linir). the bits 6 and 7 of this register are discarded. during header reception, the parity bits of the identifier are checked. if the parity bits are wrong, an identifier parity error occurs (see section 33.7.3.9 ). only the 6 least significant bits of the idchr field are updated with the received iden tifier. the bits 6 and 7 are stuck at 0. ? pardis = 1: during header transmission, all the bits of the idchr field of the lin identifier register (us_linir) are sent on the bus. during header reception, all the bits of the idchr field are updated with the received identifier.
604 6438fCatarmC21-jun-10 at91sam9g45 33.7.8.9 node action in function of the identifier, the node is concerned, or not, by the lin response. consequently, after sending or receiving the identifier, the us art must be configured. there are three possi- ble configurations: ? publish: the node sends the response. ? subscribe: the node receives the response. ? ignore: the node is not concerned by the response, it does not send and does not receive the response. this configuration is made by the field, node action (nact), in the us_linmr register (see section 33.8.16 ). example: a lin cluster that contains a master and two slaves: ? data transfer from the master to the slave 1 and to the slave 2: nact(master)=publish nact(slave1)=subscribe nact(slave2)=subscribe ? data transfer from the master to the slave 1 only: nact(master)=publish nact(slave1)=subscribe nact(slave2)=ignore ? data transfer from the slave 1 to the master: nact(master)=subscribe nact(slave1)=publish nact(slave2)=ignore ? data transfer from the slave1 to the slave2: nact(master)=ignore nact(slave1)=publish nact(slave2)=subscribe ? data transfer from the slave2 to the master and to the slave1: nact(master)=subscribe nact(slave1)=subscribe nact(slave2)=publish
605 6438fCatarmC21-jun-10 at91sam9g45 33.7.8.10 response data length the lin response data length is the number of data fields (bytes) of the response excluding the checksum. the response data length can either be configur ed by the user or be defined automatically by bits 4 and 5 of the identifier (compatibility to lin specification 1.1). the user can choose between these two modes by the dlm bit of the lin mode register (us_linmr): ? dlm = 0: the response data length is configured by the user via the dlc field of the lin mode register (us_linmr). the response data length is equal to (dlc + 1) bytes. dlc can be programmed from 0 to 255, so the response can contain from 1 data byte up to 256 data bytes. ? dlm = 1: the response data length is de fined by the identifier (idchr in us_linir) according to the table below. the dlc field of the lin mode register (us_linmr) is discarded. the response can contain 2 or 4 or 8 data bytes. figure 33-44. response data length table 33-15. response data length if dlm = 1 idchr[5] idchr[4] response data length [bytes] 00 2 01 2 10 4 11 8 user configuration: 1 - 256 data fields (dlc+1) identifier configuration: 2/4/8 data fields sync break sync field identifier field checksum field data field data field data field data field
606 6438fCatarmC21-jun-10 at91sam9g45 33.7.8.11 checksum the last field of a frame is the checksum. the checksum contains the inverted 8- bit sum with carry, over all data bytes or all data bytes and the protected identifier. checksum calculation over the data bytes only is called classic checks um and it is used for communication with lin 1.3 slaves. checksum calculation over the data by tes and the protected identifier byte is called enhanced checksum and it is used for communication with lin 2.0 slaves. the usart can be configured to: ? send/check an enhanced checksum automatically (chkdis = 0 & chktyp = 0) ? send/check a classic checksum automatically (chkdis = 0 & chktyp = 1) ? not send/check a checksum (chkdis = 1) this configuration is made by the checksum type (chktyp) and ch ecksum disable (chkdis) fields of the lin mode register (us_linmr). if the checksum feature is disabled, the user can send it manually all the same, by considering the checksum as a normal data byte and by adding 1 to the response data length (see section 33.7.8.10 ).
607 6438fCatarmC21-jun-10 at91sam9g45 33.7.8.12 frame slot mode this mode is useful only for master nodes. it respects the following rule: each frame slot shall be longer than or equal to tframe_maximum. if the frame slot mode is enabled (fsdis = 0) and a frame transfer has been completed, the txrdy flag is set again only after tframe_maximum delay, from the start of frame. so the mas- ter node cannot send a new header if the frame slot duration of the previous frame is inferior to tframe_maximum. if the frame slot mode is disabled (fdis = 1) and a frame transfer has been completed, the txrdy flag is set again immediately. the tframe_maximum is calculated as below: if the checksum is sent (chkdis = 0): ? theader_nominal = 34 x tbit ? tresponse_nominal = 10 x (ndata + 1) x tbit ? tframe_maximum = 1.4 x (theader_nominal + tresponse_nominal + 1) (note:) ? tframe_maximum = 1.4 x (34 + 10 x (dlc + 1 + 1) + 1) x tbit ? tframe_maximum = (77 + 14 x dlc) x tbit if the checksum is not sent (chkdis = 1): ? theader_nominal = 34 x tbit ? tresponse_nominal = 10 x ndata x tbit ? tframe_maximum = 1.4 x (theader_nominal + tresponse_nominal + 1 (note:) ) ? tframe_maximum = 1.4 x (34 + 10 x (dlc + 1) + 1) x tbit ? tframe_maximum = (63 + 14 x dlc) x tbit note: the term +1 leads to an integer re sult for tframe_max (lin specification 1.3) figure 33-45. frame slot mode break synch protected identifier data n checksum header inter- frame space response space frame frame slot = tframe_maximum response txrdy write us_thr write us_linid data 1 data 2 data 3 data3 data n-1 data n frame slot mode disabled frame slot mode enabled lintc data 1
608 6438fCatarmC21-jun-10 at91sam9g45 33.7.8.13 lin errors 33.7.8.14 bit error this error is generated when the usart is transmitting and if the transmitted value on the tx line is different from the value sampled on the rx line. if a bit error is detected, the transmission is aborted at the next byte border. 33.7.8.15 inconsistent synch field error this error is generated in slave node configurati on if the synch field character received is other than 0x55. 33.7.8.16 parity error this error is generated if the parity of the identi fier is wrong. this error can be generated only if the parity feature is enabled (pardis = 0). 33.7.8.17 checksum error this error is set if th e received checksum is wrong. this error can be generated only if the checksum feature is enabled (chkdis = 0). 33.7.8.18 slave not responding error this error is set when the usart expects a response from another node (nact = sub- scribe) but no valid message appears on the bus within the time frame given by the maximum length of the message frame, tframe_maximum (see section 33.7.8.12 ). this error is disabled if the usart does not expect any message (nact = publish or nact = ignore).
609 6438fCatarmC21-jun-10 at91sam9g45 33.7.8.19 lin frame handling 33.7.8.20 master node configuration ? write txen and rxen in us_cr to enable both the transmitter and the receiver. ? write usart_mode in us_mr to select the lin mode and the master node configuration. ? write cd and fp in us_brgr to configure the baud rate. ? write nact, pardis, chkdis, chktype, dlcm, fdis and dlc in us_linmr to configure the frame transfer. ? check that txrdy in us_csr is set to 1 write idchr in us_linir to send the header what comes next depends on the nact configuration: ? case 1: nact = publish, the usart sends the response C wait until txrdy in us_csr rises C write tchr in us_thr to send a byte C if all the data have not been written, redo the two previous steps C wait until lintc in us_csr rises C check the lin errors ? case 2: nact = subscribe, the usart receives the response C wait until rxrdy in us_csr rises C read rchr in us_rhr C if all the data have not been read, redo the two previous steps C wait until lintc in us_csr rises C check the lin errors ? case 3: nact = ignore, the usart is not concerned by the response C wait until lintc in us_csr rises C check the lin errors
610 6438fCatarmC21-jun-10 at91sam9g45 figure 33-46. master node configuration, nact = publish figure 33-47. master node configur ation, nact=subscribe frame break synch protected identifier data 1 data n checksum txrdy write us_thr write us_linir data 1 data 2 data 3 data n-1 data n rxrdy header inter- frame space response space frame slot = tframe_maximum response data3 lintc fsdis=1 fsdis=0 break synch protected identifier data 1 data n checksum txrdy read us_rhr write us_linir data 1 data n-1 data n-1 rxrdy data n data n-2 header inter- frame space response space frame frame slot = tframe_maximum response data3 lintc fsdis=0 fsdis=1
611 6438fCatarmC21-jun-10 at91sam9g45 figure 33-48. master node configuration, nact=ignore 33.7.8.21 slave node configuration ? write txen and rxen in us_cr to enable both the transmitter and the receiver. ? write usart_mode in us_mr to select the lin mode and the slave node configuration. ? write cd and fp in us_brgr to configure the baud rate. ? wait until linid in us_csr rises ? check linisfe and linpe errors ? read idchr in us_rhr write nact, pardis, chkdis, chktype, dlcm and dlc in us_linmr to configure the frame transfer. important : if the nact configuration for this frame is publish, the us_linmr register, must be write with nact = publish even if this field is already correctly configured, in order to set the txready flag and the corresponding pdc write transfer request. what comes next depends on the nact configuration: ? case 1: nact = publish, the lin controller sends the response C wait until txrdy in us_csr rises C write tchr in us_thr to send a byte C if all the data have not been written, redo the two previous steps C wait until lintc in us_csr rises C check the lin errors ? case 2: nact = subscribe, the usart receives the response C wait until rxrdy in us_csr rises C read rchr in us_rhr C if all the data have not been read, redo the two previous steps C wait until lintc in us_csr rises C check the lin errors ? case 3: nact = ignore, the usart is not concerned by the response C wait until lintc in us_csr rises txrdy write us_linir rxrdy lintc break synch protected identifier data 1 data n checksum data n-1 header inter- frame space response space frame frame slot = tframe_maximum response data3 fsdis=1 fsdis=0
612 6438fCatarmC21-jun-10 at91sam9g45 C check the lin errors figure 33-49. slave node configuration, nact = publish figure 33-50. slave node configuration, nact = subscribe figure 33-51. slave node configurat ion, nact = ignore 33.7.8.22 lin frame handling with the peripheral dma controller the usart can be used in association with the peripheral dma controller (pdc) in order to transfer data directly into/from the on- and off-chip memories without any processor intervention. break synch protected identifier data 1 data n checksum txrdy write us_thr read us_linid data 1 data 3 data n-1 data n rxrdy linidrx data 2 lintc txrdy read us_rhr read us_linid rxrdy linidrx lintc break synch protected identifier data 1 data n checksum data 1 data n-1 data n-1 data n data n-2 txrdy read us_rhr read us_linid rxrdy linidrx lintc break synch protected identifier data 1 data n checksum data n-1
613 6438fCatarmC21-jun-10 at91sam9g45 the pdc uses the trigger flags, txrdy and rxrdy, to write or read into the usart. the pdc always writes in the transmit holding register (us_thr) and it always reads in the receive holding register (us_rhr). the size of the da ta written or read by the pdc in the usart is always a byte. 33.7.8.23 master node configuration the user can choose between two pdc modes by the pdcm bit in the lin mode register (us_linmr): ? pdcm = 1: the lin configuration is stored in the write buffer and it is written by the pdc in the transmit holding register us_thr (instead of the lin mode register us_linmr). because the pdc transfer size is limited to a by te, the transfer is split into two accesses. during the first access the bits, nact, pardis, chkdis, chktyp, dlm and fdis are written. during the second access the 8-bit dlc field is written. ? pdcm = 0: the lin configuration is not stored in the write buffer and it must be written by the user in the lin mode register (us_linmr). the write buffer also contains the identifier and the data, if the usart sends the response (nact = publish). the read buffer contains the data if the usart receives the response (nact = subscribe). figure 33-52. master node with pdc (pdcm=1) | | | | | | | | nact pardis chkdis chktyp dlm fsdis dlc identifier data 0 data n write buffer pdc (dma) rxrdy usart3 lin controller apb bus nact pardis chkdis chktyp dlm fsdis dlc identifier data 0 data n write buffer pdc (dma) rxrdy txrdy usart3 lin controller apb bus read buffer node action = publish node action = subscribe
614 6438fCatarmC21-jun-10 at91sam9g45 figure 33-53. master node with pdc (pdcm=0) 33.7.8.24 slave node configuration in this configuration, the pdc transfers only the data. the identifier must be read by the user in the lin identifier register (us_linir). the lin mode must be written by the user in the lin mode register (us_linmr). the write buffer contains the data if the usart sends the response (nact=publish). the read buffer contains the data if the usart receives the response (nact=subscribe). figure 33-54. slave node with pdc | | | | rxrdy txrdy apb bus usart3 lin controller data 0 data n | | | | write buffer pdc (dma) usart3 lin controller read buffer node action = publish node action = subscribe pdc (dma) rxrdy apb bus identifier data 0 data n write buffer identifier | | | | | | | | data 0 data n pdc (dma) rxrdy usart3 lin controller apb bus read buffer nact = subscribe data 0 data n pdc (dma) txrdy usart3 lin controller apb bus write buffer
615 6438fCatarmC21-jun-10 at91sam9g45 33.7.8.25 wake-up request any node in a sleeping lin cluster may request a wake-up. in the lin 2.0 specification, the wakeup reques t is issued by forcing the bus to the dominant state from 250 s to 5 ms. for this, it is necessa ry to send the character 0xf0 in order to impose 5 successive dominant bits. whatever the baud rate is, this character respects the specified timings. ? baud rate min = 1 kbit/s -> tbit = 1ms -> 5 tbits = 5 ms ? baud rate max = 20 kbit/s -> tbi t= 50 s -> 5 tbits = 250 s in the lin 1.3 specification, the wakeup request should be generated with the character 0x80 in order to impose 8 successive dominant bits. the user can choose by the wkuptyp bit in the lin mode register (us_linmr) either to send a lin 2.0 wakeup request (wkuptyp=0) or to send a lin 1.3 wakeup request (wkuptyp=1). a wake-up request is transmitte d by writing the control regist er (us_cr) with the linwkup bit at 1. once the transfer is completed, the lintc flag is asserted in the status register (us_sr). it is cleared by writing the control re gister (us_cr) with the rststa bit at 1.
616 6438fCatarmC21-jun-10 at91sam9g45 33.7.8.26 bus idle time-out if the lin bus is inactive for a certain duration, the slave nodes shall automatically enter in sleep mode. in the lin 2.0 specification, this time-out is fixed at 4 seconds. in the lin 1.3 specifica- tion, it is fixed at 25000 tbits. in slave node configuration, the receiver time -out detects an idle condition on the rxd line. when a time-out is detected, the bit timeout in the channel status register (us_csr) rises and can generate an interrupt, thus indicating to the driver to go into sleep mode. the time-out delay period (during which the receiver waits for a new character) is programmed in the to field of the receiver time-out regist er (us_rtor). if the to field is programmed at 0, the receiver time-out is disabled and no time-out is detected. the timeout bit in us_csr remains at 0. otherwise, the receiver loads a 17-bit counter with the value programmed in to. this counter is decremented at each bit per iod and reloaded each time a new character is received. if the counter reaches 0, the timeout bit in the status register rises. if sttto is performed, the counter clock is stopped until a first character is received. if retto is performed, the counter starts counting down immediately from the value to. table 33-16. receiver time-out programming lin specification baud rate time-out period to 2.0 1 000 bit/s 4s 4 000 2 400 bit/s 9 600 9 600 bit/s 38 400 19 200 bit/s 76 800 20 000 bit/s 80 000 1.3 - 25 000 tbits 25 000
617 6438fCatarmC21-jun-10 at91sam9g45 33.7.9 test modes the usart can be programmed to operate in three different test modes. the internal loopback capability allows on-boar d diagnostics. in the loopback mode the usart interface pins are dis- connected or not and reconfigured for loopback internally or externally. 33.7.9.1 normal mode normal mode connects the rxd pin on the receiver input and the transmitter output on the txd pin. figure 33-55. normal mode configuration 33.7.9.2 automatic echo mode automatic echo mode allows bit-by-bit retransmission. when a bit is received on the rxd pin, it is sent to the txd pin, as shown in figure 33-56 . programming the transmitter has no effect on the txd pin. the rxd pin is still connected to the receiver input, thus the receiver remains active. figure 33-56. automatic echo mode configuration 33.7.9.3 local loopback mode local loopback mode c onnects the output of the transmitter directly to the input of the receiver, as shown in figure 33-57 . the txd and rxd pins are not used. the rxd pin has no effect on the receiver and the txd pin is continuously driven high, as in idle state. figure 33-57. local loopback mode configuration receiver transmitter rxd txd receiver transmitter rxd txd receiver transmitter rxd txd 1
618 6438fCatarmC21-jun-10 at91sam9g45 33.7.9.4 remote loopback mode remote loopback mode directly connects the rxd pin to the txd pin, as shown in figure 33-58 . the transmitter and the receiver are disabled an d have no effect. this mode allows bit-by-bit retransmission. figure 33-58. remote loopback mode configuration receiver transmitter rxd txd 1
619 6438fCatarmC21-jun-10 at91sam9g45 33.8 universal synchronous async hronous receiver transmitter (usart) user interface notes: 1. write is possible only in lin master node configuration. table 33-17. register mapping offset register name access reset 0x0000 control register us_cr write-only C 0x0004 mode register us_mr read-write C 0x0008 interrupt enable register us_ier write-only C 0x000c interrupt disable register us_idr write-only C 0x0010 interrupt mask register us_imr read-only 0x0 0x0014 channel status register us_csr read-only C 0x0018 receiver holding register us_rhr read-only 0x0 0x001c transmitter holding register us_thr write-only C 0x0020 baud rate generator register us_brgr read-write 0x0 0x0024 receiver time-out register us_rtor read-write 0x0 0x0028 transmitter timeguard register us_ttgr read-write 0x0 0x2c - 0x3c reserved C C C 0x0040 fi di ratio regist er us_fidi read-write 0x174 0x0044 number of errors register us_ner read-only C 0x0048 reserved C C C 0x004c irda filter regi ster us_if read-write 0x0 0x0050 manchester encoder decoder register us_man read-write 0x30011004 0x0054 lin mode register us_linmr read-write 0x0 0x0058 lin identifier register us_linir read-write (1) 0x0 0x5c - 0xfc reserved C C C 0x100 - 0x128 reserved for pdc registers C C C
620 6438fCatarmC21-jun-10 at91sam9g45 33.8.1 usart control register name: us_cr addresses: 0xfff8c000 (0), 0xfff90000 (1), 0xfff94000 (2), 0xfff98000 (3) access: write-only ? rstrx: reset receiver 0: no effect. 1: resets the receiver. ? rsttx: reset transmitter 0: no effect. 1: resets the transmitter. ? rxen: receiver enable 0: no effect. 1: enables the receiver, if rxdis is 0. ? rxdis: receiver disable 0: no effect. 1: disables the receiver. ? txen: transmitter enable 0: no effect. 1: enables the transmitter if txdis is 0. ? txdis: transmitter disable 0: no effect. 1: disables the transmitter. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 C C linwkup linabt rtsdis/rcs rtsen/fcs C C 15 14 13 12 11 10 9 8 retto rstnack rstit senda sttto stpbrk sttbrk rststa 76543210 txdis txen rxdis rxen rsttx rstrx C C
621 6438fCatarmC21-jun-10 at91sam9g45 ? rststa: reset status bits 0: no effect. 1: resets the status bits pare, frame, ovre, manerr, linbe, linsfe, linipe, lince, linsnre and rxbrk in us_csr. ? sttbrk: start break 0: no effect. 1: starts transmission of a break after the characters present in us_thr and the transmit shi ft register have been trans- mitted. no effect if a break is already being transmitted. ? stpbrk: stop break 0: no effect. 1: stops transmission of the break after a minimum of one char acter length and transmits a high level during 12-bit periods. no effect if no break is being transmitted. ? sttto: start time-out 0: no effect. 1: starts waiting for a character before clocking the time-out counter. resets the status bit timeout in us_csr. ? senda: send address 0: no effect. 1: in multidrop mode only, the next character written to the us_thr is sent with the address bit set. ? rstit: reset iterations 0: no effect. 1: resets iteration in us_csr. no e ffect if the iso7816 is not enabled. ? rstnack: reset non acknowledge 0: no effect 1: resets nack in us_csr. ? retto: rearm time-out 0: no effect 1: restart time-out ? rtsen/fcs: request to send enable/force spi chip select C if usart does not operate in spi master mode (usart_mode 0xe): 0: no effect. 1: drives the pin rts to 0. C if usart operates in spi master mode (usart_mode = 0xe): fcs = 0: no effect. fcs = 1: forces the slave select line nss (rts pin) to 0, ev en if usart is no transmitting, in order to address spi slave devices supporting the csaat mode (chip select active after transfer).
622 6438fCatarmC21-jun-10 at91sam9g45 ? rtsdis/rcs: request to send disable/release spi chip select C if usart does not operate in spi master mode (usart_mode 0xe): 0: no effect. 1: drives the pin rts to 1. C if usart operates in spi master mode (usart_mode = 0xe): rcs = 0: no effect. rcs = 1: releases the slave select line nss (rts pin). ? linabt: abort lin transmission 0: no effect. 1: abort the current lin transmission. ? linwkup: send lin wakeup signal 0: no effect: 1: sends a wakeup signal on the lin bus.
623 6438fCatarmC21-jun-10 at91sam9g45 33.8.2 usart mode register name: us_mr addresses: 0xfff8c004 (0), 0xfff90004 (1), 0xfff94004 (2), 0xfff98004 (3) access: read-write ? usart_mode ? usclks: clock selection 31 30 29 28 27 26 25 24 onebit modsyncC man filter C max_iteration 23 22 21 20 19 18 17 16 var_sync dsnack inack over clko mode9 msbf/cpol 15 14 13 12 11 10 9 8 chmode nbstop par sync/cpha 76543210 chrl usclks usart_mode usart_mode mode of the usart 0000normal 0001rs485 0 0 1 0 hardware handshaking 0 1 0 0 is07816 protocol: t = 0 0 1 1 0 is07816 protocol: t = 1 1000irda 1 0 1 0 lin master 1011lin slave 1110spi master 1 1 1 1 spi slave others reserved usclks selected clock 00mck 0 1 mck/div (div = 8) 10reserved 11sck
624 6438fCatarmC21-jun-10 at91sam9g45 ? chrl: character length. ? sync/cpha: synchronous mode select or spi clock phase C if usart does not operate in spi mode (usart_mode is 0xe and 0xf): sync = 0: usart operates in asynchronous mode. sync = 1: usart operates in synchronous mode. C if usart operates in spi mode (usart_mode = 0xe or 0xf): cpha = 0: data is changed on the leading edge of spck and captured on the following edge of spck. cpha = 1: data is captured on the leading edge of spck and changed on the following edge of spck. cpha determines which edge of spck causes data to change and which edge causes data to be captured. cpha is used with cpol to produce the required clock/data relationship between master and slave devices. ? par: parity type ? nbstop: number of stop bits ? chmode: channel mode chrl character length 0 0 5 bits 0 1 6 bits 1 0 7 bits 1 1 8 bits par parity type 0 0 0 even parity 001odd parity 0 1 0 parity forced to 0 (space) 0 1 1 parity forced to 1 (mark) 1 0 x no parity 1 1 x multidrop mode nbstop asynchronous (sync = 0) synchronous (sync = 1) 0 0 1 stop bit 1 stop bit 0 1 1.5 stop bits reserved 1 0 2 stop bits 2 stop bits 1 1 reserved reserved chmode mode description 0 0 normal mode
625 6438fCatarmC21-jun-10 at91sam9g45 ? msbf/cpol: bit order or spi clock polarity C if usart does not operate in spi mode (usart_mode 0xe and 0xf): msbf = 0: least significant bit is sent/received first. msbf = 1: most significant bit is sent/received first. C if usart operates in spi mode (slave or master, usart_mode = 0xe or 0xf): cpol = 0: the inactive state va lue of spck is logic level zero. cpol = 1: the inactive state value of spck is logic level one. cpol is used to determine the inactive state value of the se rial clock (spck). it is used with cpha to produce the required clock/data relationship between master and slave devices. ? mode9: 9-bit character length 0: chrl defines character length. 1: 9-bit character length. ? clko: clock output select 0: the usart does not drive the sck pin. 1: the usart drives the sck pin if usclks does not select the external clock sck. ? over: oversampling mode 0: 16x oversampling. 1: 8x oversampling. ? inack: inhibit non acknowledge 0: the nack is generated. 1: the nack is not generated. ? dsnack: disable successive nack 0: nack is sent on the iso line as soon as a parity erro r occurs in the received character (unless inack is set). 1: successive parity errors are counted up to the value spec ified in the max_iteration field. these parity errors gener- ate a nack on the iso line. as soon as this value is r eached, no additional nack is sent on the iso line. the flag iteration is asserted. ? var_sync: variable synchronization of command/data sync start frame delimiter 0: user defined configuration of command or data sync field depending on sync value. 1: the sync field is updated when a char acter is written into us_thr register. ? max_iteration defines the maximum number of iterations in mode iso7816, protocol t= 0. 0 1 automatic echo. receiver input is connected to the txd pin. 1 0 local loopback. transmitter output is connected to the receiver input. 1 1 remote loopback. rxd pin is internally connected to the txd pin.
626 6438fCatarmC21-jun-10 at91sam9g45 ? filter: infrared receive line filter 0: the usart does not filter the receive line. 1: the usart filters the receive line using a three-sample filter (1/16-bit clock) (2 over 3 majority). ? man: manchester encoder/decoder enable 0: manchester encoder/decoder are disabled. 1: manchester encoder/decoder are enabled. ? modsync : manchester synchronization mode 0:the manchester start bit is a 0 to 1 transition 1: the manchester start bit is a 1 to 0 transition. ? onebit: start frame delimiter selector 0: start frame delimiter is command or data sync. 1: start frame delimiter is one bit.
627 6438fCatarmC21-jun-10 at91sam9g45 33.8.3 usart interrupt enable register name: us_ier addresses: 0xfff8c008 (0), 0xfff90008 (1 ), 0xfff94008 (2), 0xfff98008 (3) access: write-only ? rxrdy: rxrdy interrupt enable ? txrdy: txrdy interrupt enable ? rxbrk: receiver break interrupt enable ? endrx: end of receive transfer interrupt enable ? endtx: end of transmit interrupt enable ? ovre: overrun error interrupt enable ? frame: framing error interrupt enable ? pare: parity error interrupt enable ? timeout: time-out interrupt enable ? txempty: txempty interrupt enable ? iter/unre: iteration or spi underrun error interrupt enable ? txbufe: buffer empty interrupt enable ? rxbuff: buffer full interrupt enable ? nack/linbk: non acknowledge or lin break sent or lin break received interrupt enable ? linid: lin identifier sent or lin identifier received interrupt enable ? lintc: lin transfer completed interrupt enable ? ctsic: clear to send input change interrupt enable ? mane: manchester error interrupt enable 31 30 29 28 27 26 25 24 C C linsnre lince linipe linisfe linbe mane 23 22 21 20 19 18 17 16 CCCCctsic C C C 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff txbufe iter/unre txempty timeout 76543210 pare frame ovre endtx endrx rxbrk txrdy rxrdy
628 6438fCatarmC21-jun-10 at91sam9g45 ? linbe: lin bus error interrupt enable ? linisfe: lin inconsistent synch field error interrupt enable ? linipe: lin identifier parity interrupt enable ? lince: lin checksum error interrupt enable ? linsnre: lin slave not responding error interrupt enable
629 6438fCatarmC21-jun-10 at91sam9g45 33.8.4 usart interrupt disable register name: us_idr addresses: 0xfff8c00c (0), 0xfff9000c (1), 0xfff9400c (2), 0xfff9800c (3) access: write-only ? rxrdy: rxrdy interrupt disable ? txrdy: txrdy interrupt disable ? rxbrk: receiver bre ak interrupt disable ? endrx: end of receive transfer interrupt disable ? endtx: end of transmit interrupt disable ? ovre: overrun error interrupt disable ? frame: framing error interrupt disable ? pare: parity error interrupt disable ? timeout: time-out interrupt disable ? txempty: txempty interrupt disable ? iter/unre: iteration or spi underrun error interrupt enable ? txbufe: buffer empty interrupt disable ? rxbuff: buffer full interrupt disable ? nack/linbk: non acknowledge or lin break sent or lin break received interrupt disable ? linid: lin identifier sent or lin identifier received interrupt disable ? lintc: lin transfer completed interrupt disable ? ctsic: clear to send input change interrupt disable ? mane: manchester error interrupt disable 31 30 29 28 27 26 25 24 C C linsnre lince linipe linisfe linbe mane 23 22 21 20 19 18 17 16 CCCCctsic C C C 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff txbufe iter/unre txempty timeout 76543210 pare frame ovre endtx endrx rxbrk txrdy rxrdy
630 6438fCatarmC21-jun-10 at91sam9g45 ? linbe: lin bus error interrupt disable ? linisfe: lin inconsistent synch field error interrupt disable ? linipe: lin identifier parity interrupt disable ? lince: lin checksum error interrupt disable ? linsnre: lin slave not responding error interrupt disable
631 6438fCatarmC21-jun-10 at91sam9g45 33.8.5 usart interrupt mask register name: us_imr addresses: 0xfff8c010 (0), 0xfff90010 (1), 0xfff94010 (2), 0xfff98010 (3) access: read-only ? rxrdy: rxrdy interrupt mask ? txrdy: txrdy interrupt mask ? rxbrk: receiver break interrupt mask ? endrx: end of receive transfer interrupt mask ? endtx: end of transmit interrupt mask ? ovre: overrun error interrupt mask ? frame: framing error interrupt mask ? pare: parity error interrupt mask ? timeout: time-out interrupt mask ? txempty: txempty interrupt mask ? iter/unre: iteration or spi underrun error interrupt enable ? txbufe: buffer empty interrupt mask ? rxbuff: buffer full interrupt mask ? nack/linbk: non acknowledge or lin break sent or lin break received interrupt mask ? linid: lin identifier sent or lin identifier received interrupt mask ? lintc: lin transfer completed interrupt mask ? ctsic: clear to send input change interrupt mask ? mane: manchester error interrupt mask 31 30 29 28 27 26 25 24 C C linsnre lince linipe linisfe linbe mane 23 22 21 20 19 18 17 16 CCCCctsic C C C 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff txbufe iter/unre txempty timeout 76543210 pare frame ovre endtx endrx rxbrk txrdy rxrdy
632 6438fCatarmC21-jun-10 at91sam9g45 ? linbe: lin bus error interrupt mask ? linisfe: lin inconsistent synch field error interrupt mask ? linipe: lin identifier parity interrupt mask ? lince: lin checksum error interrupt mask ? linsnre: lin slave not responding error interrupt mask
633 6438fCatarmC21-jun-10 at91sam9g45 33.8.6 usart channel status register name: us_csr addresses: 0xfff8c014 (0), 0xfff90014 (1), 0xfff94014 (2), 0xfff98014 (3) access: read-only ? rxrdy: receiver ready 0: no complete character has been received since the last read of us_rhr or the receiver is disabled. if characters were being received when the receiver was disabled, rx rdy changes to 1 when the receiver is enabled. 1: at least one complete char acter has been rece ived and us_rhr has not yet been read. ? txrdy: transmitter ready 0: a character is in the us_thr waiting to be transferred to the transmit shift register, or an sttbrk command has been requested, or the transmitter is disabled. as soon as the transmitter is enabled, txrdy becomes 1. 1: there is no char acter in the us_thr. ? rxbrk: break received/end of break 0: no break received or end of break detected since the last rststa. 1: break received or end of break detected since the last rststa. ? endrx: end of receiver transfer 0: the end of transfer signal from the receive pdc channel is inactive. 1: the end of transfer signal from the receive pdc channel is active. ? endtx: end of transmitter transfer 0: the end of transfer signal from the transmit pdc channel is inactive. 1: the end of transfer signal from the transmit pdc channel is active. ? ovre: overrun error 0: no overrun error has occurred since the last rststa. 1: at least one overrun error has occurred since the last rststa. 31 30 29 28 27 26 25 24 C C linsnre lince linipe linisfe linbe manerr 23 22 21 20 19 18 17 16 cts C C C ctsic C C C 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff txbufe iter/unre txempty timeout 76543210 pare frame ovre endtx endrx rxbrk txrdy rxrdy
634 6438fCatarmC21-jun-10 at91sam9g45 ? frame: framing error 0: no stop bit has been detected low since the last rststa. 1: at least one stop bit has been detected low since the last rststa. ? pare: parity error 0: no parity error has been detected since the last rststa. 1: at least one parity error has been detected since the last rststa. ? timeout: receiver time-out 0: there has not been a time-out since t he last start time-out command (sttto in us_cr) or the time-out register is 0. 1: there has been a time-out since the last start time-out command (sttto in us_cr). ? txempty: transmitter empty 0: there are characters in either us_thr or the tr ansmit shift register, or the transmitter is disabled. 1: there are no characters in us_thr, nor in the transmit shift register. ? iter/unre: max number of repetitions reached or spi underrun error C if usart does not operate in spi slave mode (usart_mode 0xf): iter = 0: maximum number of repetitions has not been reached since the last rststa. iter = 1: maximum number of repetitions has been reached since the last rststa. C if usart operates in spi slave mode (usart_mode = 0xf): unre = 0: no spi underrun error has occurred since the last rststa. unre = 1: at least one spi underrun error has occurred since the last rststa. ? txbufe: transmission buffer empty 0: the signal buffer empty from the transmit pdc channel is inactive. 1: the signal buffer empty from the transmit pdc channel is active. ? rxbuff: reception buffer full 0: the signal buffer full from the receive pdc channel is inactive. 1: the signal buffer full from th e receive pdc channel is active. ? nack/linbk non acknowledge or lin break sent or lin break received C if usart does not operate in lin mode (usart_mode 0xa and 0xb): 0: no non acknowledge has not been detected since the last rstnack. C 1: at least one non acknowledge has been detected since the last rstnack.if usart operates in lin master mode (usart_mode = 0xa): 0: no lin break has been sent since the last rststa. C 1:at least one lin break has been sent since the last rststaif usart operates in lin slave mode (usart_mode = 0xb): 0: no lin break has received sent since the last rststa. C 1:at least one lin break has been received since the last rststa. linid: lin identifier sent or lin identifier received if usart operates in lin master mode (usart_mode = 0xa):
635 6438fCatarmC21-jun-10 at91sam9g45 0: no lin identifier has been sent since the last rststa. C 1:at least one lin identifier has been sent since the last rststa.if usart operates in lin slave mode (usart_mode = 0xb): 0: no lin identifier has been received since the last rststa. 1:at least one lin identifier has been received since the last rststa ? lintc: lin transfer completed 0: the usart is idle or a lin transfer is ongoing. 1: a lin transfer has been completed since the last rststa. ? ctsic: clear to send input change flag 0: no input change has been detected on the cts pin since the last read of us_csr. 1: at least one input change has been detected on the cts pin since the last read of us_csr. ? cts: image of cts input 0: cts is at 0. 1: cts is at 1. ? manerr: manchester error 0: no manchester error has been detected since the last rststa. 1: at least one manchester error has been detected since the last rststa. ? linbe: lin bit error 0: no bit error has been detected since the last rststa. 1: a bit error has been detected since the last rststa. ? linisfe: lin inconsistent synch field error 0: no lin inconsistent synch field erro r has been detected since the last rststa 1: the usart is configured as a slave node and a lin in consistent synch field error has been detected since the last rststa. ? linipe: lin identifier parity error 0: no lin identifier parity error has been detected since the last rststa. 1: a lin identifier parity error has been detected since the last rststa. ? lince: lin checksum error 0: no lin checksum error has been detected since the last rststa. 1: a lin checksum error has been de tected since the last rststa. ? linsnre: lin slave not responding error 0: no lin slave not responding error ha s been detected since the last rststa. 1: a lin slave not responding error has been detected since the last rststa.
636 6438fCatarmC21-jun-10 at91sam9g45
637 6438fCatarmC21-jun-10 at91sam9g45 33.8.7 usart receive holding register name: us_rhr addresses: 0xfff8c018 (0), 0xfff90018 (1), 0xfff94018 (2), 0xfff98018 (3) access: read-only ? rxchr: received character last character received if rxrdy is set. ? rxsynh: received sync 0: last character received is a data. 1: last character received is a command. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 rxsynh CCCCCCrxchr 76543210 rxchr
638 6438fCatarmC21-jun-10 at91sam9g45 33.8.8 usart transmit holding register name: us_thr addresses: 0xfff8c01c (0), 0xfff9001c (1), 0xfff9401c (2), 0xfff9801c (3) access: write-only ? txchr: character to be transmitted next character to be transmitted after the current character if txrdy is not set. ? txsynh: sync field to be transmitted 0: the next character sent is encoded as a data. start frame delimiter is data sync. 1: the next character sent is encoded as a command. start frame delimiter is command sync. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 txsynh CCCCCCtxchr 76543210 txchr
639 6438fCatarmC21-jun-10 at91sam9g45 33.8.9 usart baud rate generator register name: us_brgr addresses: 0xfff8c020 (0), 0xfff90020 (1), 0xfff94020 (2), 0xfff98020 (3) access: read-write ? cd: clock divider ? fp: fractional part 0: fractional divider is disabled. 1 - 7: baudrate resolution, defined by fp x 1/8. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCC fp 15 14 13 12 11 10 9 8 cd 76543210 cd cd usart_mode iso7816 usart_mode = iso7816 sync = 0 sync = 1 or usart_mode = spi (master or slave) over = 0 over = 1 0 baud rate clock disabled 1 to 65535 baud rate = selected clock/16/cd baud rate = selected clock/8/cd baud rate = selected clock /cd baud rate = selected clock/cd/fi_di_ratio
640 6438fCatarmC21-jun-10 at91sam9g45 33.8.10 usart receiver time-out register name: us_rtor addresses: 0xfff8c024 (0), 0xfff90024 (1), 0xfff94024 (2), 0xfff98024 (3) access: read-write ? to: time-out value 0: the receiver time-out is disabled. 1 - 131071: the receiver time-out is enabled and the time-out delay is to x bit period. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCto 15 14 13 12 11 10 9 8 to 76543210 to
641 6438fCatarmC21-jun-10 at91sam9g45 33.8.11 usart transmitter timeguard register name: us_ttgr addresses: 0xfff8c028 (0), 0xfff90028 (1), 0xfff94028 (2), 0xfff98028 (3) access: read-write ? tg: timeguard value 0: the transmitter timeguard is disabled. 1 - 255: the transmitter timeguard is enabled and the timeguard delay is tg x bit period. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 tg
642 6438fCatarmC21-jun-10 at91sam9g45 33.8.12 usart fi di ratio register name: us_fidi addresses: 0xfff8c040 (0), 0xfff90040 (1), 0xfff94040 (2), 0xfff98040 (3) access: read-write reset value: 0x174 ? fi_di_ratio: fi over di ratio value 0: if iso7816 mode is selected, the baud rate generator generates no signal. 1 - 2047: if iso7816 mode is selected, the baud rate is the clock provided on sck divided by fi_di_ratio. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCC fi_di_ratio 76543210 fi_di_ratio
643 6438fCatarmC21-jun-10 at91sam9g45 33.8.13 usart number of errors register name: us_ner addresses: 0xfff8c044 (0), 0xfff90044 (1), 0xfff94044 (2), 0xfff98044 (3) access: read-only ? nb_errors: number of errors total number of errors that occurred during an iso7816 transfer. this register automatically clears when read. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 nb_errors
644 6438fCatarmC21-jun-10 at91sam9g45 33.8.14 usart irda filter register name: us_if addresses: 0xfff8c04c (0), 0xfff9004c (1), 0xfff9404c (2), 0xfff9804c (3) access: read-write ? irda_filter: irda filter sets the filter of the irda demodulator. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 irda_filter
645 6438fCatarmC21-jun-10 at91sam9g45 33.8.15 usart manchester configuration register name: us_man addresses: 0xfff8c050 (0), 0xfff90050 (1), 0xfff94050 (2), 0xfff98050 (3) access: read-write ? tx_pl: transmitter preamble length 0: the transmitter preamble pattern generation is disabled 1 - 15: the preamble length is tx_pl x bit period ? tx_pp: transmitter preamble pattern ? tx_mpol: transmitter manchester polarity 0: logic zero is coded as a zero-to-one transition , logic one is coded as a one-to-zero transition. 1: logic zero is coded as a one-to-zero transition , logic one is coded as a zero-to-one transition. ? rx_pl: receiver preamble length 0: the receiver preamble pattern detection is disabled 1 - 15: the detected preamble length is rx_pl x bit period ? rx_pp: receiver preamble pattern detected 31 30 29 28 27 26 25 24 C drift 1 rx_mpol C C rx_pp 23 22 21 20 19 18 17 16 CCCC rx_pl 15 14 13 12 11 10 9 8 C C C tx_mpol C C tx_pp 76543210 CCCC tx_pl tx_pp preamble pattern default polari ty assumed (tx_mpol field not set) 0 0 all_one 0 1 all_zero 10zero_one 11one_zero rx_pp preamble pattern de fault polarity assumed (rx_mpol fi eld not set) 0 0 all_one 0 1 all_zero 10zero_one 11one_zero
646 6438fCatarmC21-jun-10 at91sam9g45 ? rx_mpol: receiver manchester polarity 0: logic zero is coded as a zero-to-one transition , logic one is coded as a one-to-zero transition. 1: logic zero is coded as a one-to-zero transition , logic one is coded as a zero-to-one transition. ? drift: drift compensation 0: the usart can not recover from an important clock drift 1: the usart can recover from clock drift. the 16x clock mode must be enabled. 33.8.16 usart3 lin mode register name: us_linmr access: read-write ? nact: lin node action ? pardis: parity disable 0: in master node configuration, the identifier parity is computed and sent automatically. in master node and slave node configuration, the parity is checked automatically. 1:whatever the node configuration is, the identifier parity is not computed/sent and it is not checked. ? chkdis: checksum disable 0: in master node configuration, the checksum is computed and sent automatically. in slave node configuration, the check- sum is checked automatically. 1: whatever the node configuration is, the checks um is not computed/sent and it is not checked. ? chktyp: checksum type 0: lin 2.0 enhanced checksum 1: lin 1.3 classic checksum 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCpdcm 15 14 13 12 11 10 9 8 dlc 76543210 wkuptyp fsdis dlm chktyp chkdis pardis nact nact mode description 0 0 publish: the usart transmits the response. 0 1 subscribe: the usart receives the response. 1 0 ignore: the usart does not transmit and does not receive the response. 11reserved
647 6438fCatarmC21-jun-10 at91sam9g45 ? dlm: data length mode 0: the response data length is defined by the field dlc of this register. 1: the response data length is defined by the bits 5 and 6 of the identifier (idchr in us_linir). ? fdis: frame slot mode disable 0: the frame slot mode is enabled. 1: the frame slot mode is disabled. ? wkuptyp: wakeup signal type 0: setting the bit linwkup in the control register sends a lin 2.0 wakeup signal. 1: setting the bit linwkup in the control register sends a lin 1.3 wakeup signal. ? dlc: data length control 0 - 255: defines the response data length if dlm=0,in that case the response data length is equal to dlc+1 bytes. ?pdcm: pdc mode 0: the lin mode register us_linmr is not written by the pdc. 1: the lin mode register us_linmr (excepting that flag) is written by the pdc.
648 6438fCatarmC21-jun-10 at91sam9g45 33.8.17 usart3 lin identifier register name: us_linir access: read-write or read-only ? idchr: identifier character if usart_mode=0xa (master node configuration): idchr is read-write and its value is the identifier character to be transmitted. if usart_mode=0xb (slave node configuration): idchr is read-only and its value is the last identifier character that has been received. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 idchr
649 6438fCatarmC21-jun-10 at91sam9g45
650 6438fCatarmC21-jun-10 at91sam9g45
651 6438fCatarmC21-jun-10 at91sam9g45
652 6438fCatarmC21-jun-10 at91sam9g45
653 6438fCatarmC21-jun-10 at91sam9g45
654 6438fCatarmC21-jun-10 at91sam9g45
655 6438fCatarmC21-jun-10 at91sam9g45
656 6438fCatarmC21-jun-10 at91sam9g45
657 6438fCatarmC21-jun-10 at91sam9g45
658 6438fCatarmC21-jun-10 at91sam9g45
659 6438fCatarmC21-jun-10 at91sam9g45
660 6438fCatarmC21-jun-10 at91sam9g45
661 6438fCatarmC21-jun-10 at91sam9g45 34. synchronous serial controller (ssc) 34.1 description the atmel synchronous serial controller (ssc ) provides a synchronous communication link with external devices. it supports many serial synchronous communication protocols generally used in audio and telecom applications such as i2s, short frame sync, long frame sync, etc. the ssc contains an independent receiver and transmitter and a common clock divider. the receiver and the transmitter each interface with three signals: the td/rd signal for data, the tk/rk signal for the clock and the tf/rf signal for the frame sync. the transfers can be pro- grammed to start automatically or on different events detected on the frame sync signal. the sscs high-level of programmability and its two dedicated pdc channels of up to 32 bits permit a continuous high bit rate data transfer without processor intervention. the sscs high-level of programmability and it s use of dma permit a continuous high bit rate data transfer without processor intervention. featuring connection to two pdc channels and connec tion to the dma, the ssc permits inter- facing with low processor overhead to the following: ? codecs in master or slave mode ? dac through dedicated serial interface, particularly i2s ? magnetic card reader 34.2 embedded characteristics ? provides serial synchronous communication links used in audio and telecom applications (with codecs in master or slave modes, i 2 s, tdm buses, magnetic card reader,...) ? contains an independent receiver and transmitter and a common clock divider ? offers a configurable frame sync and data length ? receiver and transmitter can be programmed to start automatically or on detection of different event on the frame sync signal ? receiver and transmitter include a data signal , a clock signal and a frame synchronization signal
662 6438fCatarmC21-jun-10 at91sam9g45 34.3 block diagram figure 34-1. block diagram ssc interface pio pdc apb bridge mck system bus peripheral bus tf tk td rf rk rd interrupt control ssc interrupt pmc
663 6438fCatarmC21-jun-10 at91sam9g45 figure 34-2. block diagram 34.4 application block diagram figure 34-3. application block diagram ssc interface pio dma apb bridge mck system bus peripheral bus tf tk td rf rk rd interrupt control ssc interrupt pmc interrupt management power management test management ssc serial audio os or rtos driver codec frame management line interface time slot management
664 6438fCatarmC21-jun-10 at91sam9g45 34.5 pin name list 34.6 product dependencies 34.6.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with pio lines. before using the ssc receiver, the pio contro ller must be configured to dedicate the ssc receiver i/o lines to the ssc peripheral mode. before using the ssc transmitter, the pio controller must be configured to dedicate the ssc transmitter i/o lines to the ssc peripheral mode. 34.6.2 power management the ssc is not continuously clocked. the ssc interface may be clocked through the power management controller (pmc), therefore the programmer must first configure the pmc to enable the ssc clock. 34.6.3 interrupt the ssc interface has an interrupt line connected to the advanced interrupt controller (aic). handling interrupts requires programming the aicbefore configuring the ssc. table 34-1. i/o lines description pin name pin description type rf receiver frame synchro input/output rk receiver clock input/output rd receiver data input tf transmitter frame synchro input/output tk transmitter clock input/output td transmitter data output table 34-2. i/o lines instance signal i/o line peripheral ssc0 rd0 pd3 a ssc0 rf0 pd5 a ssc0 rk0 pd4 a ssc0 td0 pd2 a ssc0 tf0 pd1 a ssc0 tk0 pd0 a ssc1 rd1 pd11 a ssc1 rf1 pd15 a ssc1 rk1 pd13 a ssc1 td1 pd10 a ssc1 tf1 pd14 a ssc1 tk1 pd12 a
665 6438fCatarmC21-jun-10 at91sam9g45 all ssc interrupts can be enabled/disabled config uring the ssc interrupt mask register. each pending and unmasked ssc interrupt will assert the ssc interrupt line. the ssc interrupt ser- vice routine can get the interrupt origin by reading the ssc interrupt status register. table 34-3. peripheral ids instance id ssc0 16 ssc1 17
666 6438fCatarmC21-jun-10 at91sam9g45 34.7 functional description this chapter contains the functional description of the following: ssc functional block, clock management, data format, start, transmitter, receiver and frame sync. the receiver and transmitter operate separately. however, they can work synchronously by pro- gramming the receiver to use the transmit clock and/or to start a data transfer when transmission starts. alternatively, this can be done by programming the transmitter to use the receive clock and/or to start a data transfer when reception starts. the transmitter and the receiver can be pro- grammed to operate with the clock signals provided on either the tk or rk pins. this allows the ssc to support many slave-mode data transfer s. the maximum clock speed allowed on the tk and rk pins is the master clock divided by 2. figure 34-4. ssc functional block diagram interrupt control aic user interface apb mck receive clock controller tx clock rk input clock output controller frame sync controller transmit clock controller transmit shift register start selector start selector transmit sync holding register transmit holding register rx clock tx clock tk input rd rf rk clock output controller frame sync controller receive shift register receive sync holding register receive holding register td tf tk rx clock receiver transmitter data controller txen data controller rf tf rx start rxen rc0r tx start clock divider rx start tx start
667 6438fCatarmC21-jun-10 at91sam9g45 34.7.1 clock management the transmitter clock can be generated by: ? an external clock received on the tk i/o pad ? the receiver clock ? the internal clock divider the receiver clock can be generated by: ? an external clock received on the rk i/o pad ? the transmitter clock ? the internal clock divider furthermore, the transmitter block can generate an external clock on the tk i/o pad, and the receiver block can generate an external clock on the rk i/o pad. this allows the ssc to support many master and slave mode data transfers. nvic frame sync controller clock output controller data controller start selector start selector rf rxen rc0r tx start txen tf rx start tx start interrupt control user interface apb mck receive clock controller tx clock rk input transmit clock controller transmit shift register transmit sync holding register transmit holding register rx clock tx clock tk input rd rf rk clock output controller frame sync controller receive shift register receive sync holding register receive holding register td tf tk rx clock receiver transmitter data controller clock divider rx start
668 6438fCatarmC21-jun-10 at91sam9g45 34.7.1.1 clock divider figure 34-5. divided clock block diagram the master clock divider is determined by the 12-bit field div counter and comparator (so its maximal value is 4095) in the clock mode register ssc_cmr, allowing a master clock division by up to 8190. the divided clock is provided to both the receiver and transmitter. when this field is programmed to 0, the clock divider is not used and remains inactive. when div is set to a value equal to or greater than 1, the divided clock has a frequency of mas- ter clock divided by 2 times div. each level of the divided clock has a duration of the master clock multiplied by div. this ensures a 50 % duty cycle for the divided clock regardless of whether the div value is even or odd. figure 34-6. divided clock generation 34.7.1.2 transmitter clock management the transmitter clock is generated from the receiver clock or the divider clock or an external clock scanned on the tk i/o pad. the transm itter clock is selected by the cks field in ssc_tcmr (transmit clock mode register). transmit clock can be inverted independently by the cki bits in ssc_tcmr. the transmitter can also drive the tk i/o pad cont inuously or be limited to the actual data trans- fer. the clock output is configured by the ssc_tcmr register. the transmit clock inversion (cki) bits have no effect on the clock outputs. programming the tcmr register to select tk pin mck divided clock clock divider / 2 12-bit counter ssc_cmr master clock divided clock div = 1 master clock divided clock div = 3 divided clock frequency = mck/2 divided clock frequency = mck/6 table 34-4. maximum minimum mck / 2 mck / 8190
669 6438fCatarmC21-jun-10 at91sam9g45 (cks field) and at the same time continuous transmit clock (cko field) might lead to unpredict- able results. figure 34-7. transmitter clock management 34.7.1.3 receiver clock management the receiver clock is generated from the transmitter clock or the divider clock or an external clock scanned on the rk i/o pad. the receive clock is selected by the cks field in ssc_rcmr (receive clock mode register). receive clocks can be inverted independently by the cki bits in ssc_rcmr. the receiver can also drive the rk i/o pad continuo usly or be limited to the actual data transfer. the clock output is configured by the ssc_rcmr register. the receive clock inversion (cki) bits have no effect on the clock outputs. programming the rcmr register to select rk pin (cks field) and at the same time continuous receive clock (cko field) can lead to unpredictable results. figure 34-8. receiver clock management tk (pin) receiver clock divider clock cks cko data transfer cki ckg transmitter clock clock output mux tri_state controller tri-state controller inv mux rk (pin) transmitter clock divider clock cks cko data transfer cki ckg receiver clock clock output mux tri-state controller tri-state controller inv mux
670 6438fCatarmC21-jun-10 at91sam9g45 34.7.1.4 serial clock ratio considerations the transmitter and the receiver can be programmed to operate with the clock signals provided on either the tk or rk pins. this allows the ssc to support many slave-mode data transfers. in this case, the maximum clock speed allowed on the rk pin is: C master clock divided by 2 if receiver frame synchro is input C master clock divided by 3 if receiver frame synchro is output in addition, the maximum clock speed allowed on the tk pin is: C master clock divided by 6 if transmit frame synchro is input C master clock divided by 2 if transmit frame synchro is output 34.7.2 transmitter operations a transmitted frame is triggered by a start event and can be followed by synchronization data before data transmission. the start event is configured by setting the transmit clock mode register (ssc_tcmr). see start on page 671. the frame synchronization is configured setting the transmit frame mode register (ssc_tfmr). see frame sync on page 673. to transmit data, the transmitter uses a shift re gister clocked by the transmitter clock signal and the start mode selected in the ssc_tcmr. data is written by the application to the ssc_thr register then transferred to the shift register according to the data format selected. when both the ssc_thr and the transmit shift register are empty, the status flag txempty is set in ssc_sr. when the transmit holding register is transferred in the transmit shift register, the status flag txrdy is set in ssc_sr and additional data can be loaded in the holding register. figure 34-9. transmitter block diagram transmit shift register td ssc_tfmr.fslen ssc_tfmr.datlen ssc_tcmr.sttdly ssc_tfmr.fsden ssc_tfmr.datnb ssc_tfmr.datdef ssc_tfmr.msbf ssc_tcmr.sttdly != 0 ssc_tfmr.fsden 1 0 tx controller ssc_tcmr.start rf start selector txen rx start txen rf start selector rxen rc0r tx start tx start transmitter clock tx controller counter reached sttdly ssc_rcmr.start ssc_thr ssc_tshr ssc_crtxen ssc_srtxen ssc_crtxdis
671 6438fCatarmC21-jun-10 at91sam9g45 34.7.3 receiver operations a received frame is triggered by a start event and can be followed by synchronization data before data transmission. the start event is configured setting the receive clock mode register (ssc_rcmr). see start on page 671. the frame synchronization is configured setting the receive frame mode register (ssc_rfmr). see frame sync on page 673. the receiver uses a shift register clocked by the receiver clock signal and the start mode selected in the ssc_rcmr. the data is transferred from the shift register depending on the data format selected. when the receiver shift register is full, the ssc transfers this data in the holding register, the sta- tus flag rxrdy is set in ssc_sr and the data c an be read in the receiver holding register. if another transfer occurs before read of the rhr register, the status flag overun is set in ssc_sr and the receiver shift register is transferred in the rhr register. figure 34-10. receiver block diagram 34.7.4 start the transmitter and receiver can both be programmed to start their operations when an event occurs, respectively in the transmit start sele ction (start) field of ssc_tcmr and in the receive start selection (start) field of ssc_rcmr. under the following conditions the start event is independently programmable: ? continuous. in this case, the transmission st arts as soon as a word is written in ssc_thr and the reception starts as soon as the receiver is enabled. ? synchronously with the transmitter/receiver ? on detection of a falling/rising edge on tf/rf ? on detection of a low level/high level on tf/rf ? on detection of a level change or an edge on tf/rf ssc_rfmr.msbf ssc_rfmr.datnb ssc_tcmr.start ssc_rcmr.start ssc_rhr ssc_rshr ssc_rfmr.fslen ssc_rfmr.datlen rx controller counter reached sttdly rx controller rd ssc_cr.rxen ssc_cr.rxdis ssc_sr.rxen receiver clock rf txen rx start rf rxen rc0r ssc_rcmr.sttdly != 0 receive shift register start selector start selector rx start load load
672 6438fCatarmC21-jun-10 at91sam9g45 a start can be programmed in the same manner on either side of the transmit/receive clock register (rcmr/tcmr). thus, the start coul d be on tf (transmit) or rf (receive). moreover, the receiver can start when data is detected in the bit stream with the compare functions. detection on tf/rf input/output is done by the field fsos of the transmit/receive frame mode register (tfmr/rfmr). figure 34-11. transmit start mode figure 34-12. receive pulse/ed ge start modes x tk tf (input) td (output) td (output) td (output) td (output) td (output) td (output) xbob1 x bo b1 bo b1 bo b1 bo b1 bo b1 bo b1 b1 bo x x x sttdly sttdly sttdly sttdly sttdly sttdly start = falling edge on tf start = rising edge on tf start = low level on tf start = high level on tf start = any edge on tf start = level change on tf x rk rf (input) rd (input) rd (input) rd (input) rd (input) rd (input) rd (input) xbob1 x bo b1 bo b1 bo b1 bo b1 bo b1 bo b1 b1 bo x x x sttdly sttdly sttdly sttdly sttdly sttdly start = falling edge on rf start = rising edge on rf start = low level on rf start = high level on rf start = any edge on rf start = level change on rf
673 6438fCatarmC21-jun-10 at91sam9g45 34.7.5 frame sync the transmitter and receiver frame sync pins, tf and rf, can be programmed to generate different kinds of frame synchron ization signals. the frame sync output selection (fsos) field in the receive frame mode register (ssc_rfmr) and in the transmit frame mode register (ssc_tfmr) are used to select the required waveform. ? programmable low or high levels during data transfer are supported. ? programmable high levels before the start of data transfers or toggling are also supported. if a pulse waveform is selected, the frame sync length (fslen) field in ssc_rfmr and ssc_tfmr programs the length of the pulse, from 1 bit time up to 256 bit time. the periodicity of the receive and transmit frame sync pulse output can be programmed through the period divider selection ( period) field in ssc_rcmr and ssc_tcmr. 34.7.5.1 frame sync data frame sync data transmits or receives a specific tag during the frame sync signal. during the frame sync signal, the receiver can sample the rd line and store the data in the receive sync holding register and the transmitter can transfer transmit sync holding register in the shifter register. the data length to be sampled/shifted out during the frame sync signal is programmed by the fslen field in ssc_rfmr/ssc_tfmr and has a maximum value of 16. concerning the receive frame sync data operation, if the frame sync length is equal to or lower than the delay between the start event and the actual data reception, the data sampling operation is performed in the re ceive sync holding register thr ough the receive shift register. the transmit frame sync operation is performed by the transmitter only if the bit frame sync data enable (fsden) in ssc_tfmr is set. if the frame sync length is equal to or lower than the delay between the start event and the actual data transmission, the normal transmission has priority and the data contained in the transmit sync holding register is transferred in the trans- mit register, then shifted out. 34.7.5.2 frame sync edge detection the frame sync edge detection is programmed by the fsedge field in ssc_rfmr/ssc_tfmr. this sets the corres ponding flags rxsyn/txsyn in the ssc status register (ssc_sr) on frame synchro edge detection (signals rf/tf). 34.7.6 receive compare modes figure 34-13. receive compare modes cmp0 cmp3 cmp2 cmp1 ignored b0 b2 b1 start rk rd (input) fslen up to 16 bits (4 in this example) stdly datlen
674 6438fCatarmC21-jun-10 at91sam9g45 34.7.6.1 compare functions length of the comparison patterns (compare 0, compare 1) and thus the number of bits they are compared to is defined by fslen, but with a maximum value of 16 bits. comparison is always done by comparing the last bits received with the comparison pattern. compare 0 can be one start event of the receiver. in this case, the receiver compares at each new sample the last bits received at the compare 0 pattern contained in the compare 0 register (ssc_rc0r). when this start event is selected, the user can program the receiver to start a new data transfer either by writing a new compare 0, or by receiving continuously until compare 1 occurs. this selection is done with the bit (stop) in ssc_rcmr. 34.7.7 data format the data framing format of both the transmitter and the receiver are programmable through the transmitter frame mode register (ssc_tfmr) and the receiver frame mode register (ssc_rfmr). in either case, the user can independently select: ? the event that starts the data transfer (start) ? the delay in number of bit periods between the start event and the first data bit (sttdly) ? the length of the data (datlen) ? the number of data to be transferred for each start event (datnb). ? the length of synchronization transferred for each start event (fslen) ? the bit sense: most or lowest significant bit first (msbf) additionally, the transmitter can be used to tr ansfer synchronization and select the level driven on the td pin while not in data transfer operation. this is done respectively by the frame sync data enable (fsden) and by the data default value (datdef) bits in ssc_tfmr.
675 6438fCatarmC21-jun-10 at91sam9g45 figure 34-14. transmit and receive frame format in edge/pulse start modes note: 1. example of input on falling edge of tf/rf. figure 34-15. transmit frame format in continuous mode table 34-5. data frame registers transmitter receiver field length comment ssc_tfmr ssc_rfmr datlen up to 32 size of word ssc_tfmr ssc_rfmr datnb up to 16 number of words transmitted in frame ssc_tfmr ssc_rfmr msbf most significant bit first ssc_tfmr ssc_rfmr fslen up to 16 size of synchro data register ssc_tfmr datdef 0 or 1 data default value ended ssc_tfmr fsden enable send ssc_tshr ssc_tcmr ssc_rcmr period up to 512 frame size ssc_tcmr ssc_rcmr sttdly up to 255 size of transmit start delay sync data default sttdly sync data ignored rd default data datlen data data data datlen data data default default ignored sync data sync data fslen tf/rf (1) start start from ssc_tshr from ssc_thr from ssc_thr from ssc_thr from ssc_thr to ssc_rhr to ssc_rhr to ssc_rshr td (if fsden = 0) td (if fsden = 1) datnb period fromdatdef fromdatdef from datdef from datdef datlen data datlen data default start from ssc_thr from ssc_thr td start: 1. txempty set to 1 2. write into the ssc_thr
676 6438fCatarmC21-jun-10 at91sam9g45 note: 1. sttdly is set to 0. in this example, ssc_thr is loaded twice. fsden value has no effect on the transmission. syncdata cannot be output in continuous mode. figure 34-16. receive frame format in continuous mode note: 1. sttdly is set to 0. 34.7.8 loop mode the receiver can be programmed to receive transmissions from the transmitter. this is done by setting the loop mode (loop) bit in ssc_rfmr. in this case, rd is connected to td, rf is connected to tf and rk is connected to tk. 34.7.9 interrupt most bits in ssc_sr have a corresponding bit in interrupt management registers. the ssc can be programmed to generate an interrupt when it detects an event. the interrupt is controlled by writing ssc_ier (interrupt enable register) and ssc_idr (interrupt disable reg- ister) these registers enable and disable, respectively, the corresponding interrupt by setting and clearing the corresponding bit in ssc_imr (interrupt mask register), which controls the generation of interrupts by asserting the ssc interrupt line connected to the aic. figure 34-17. interrupt block diagram data datlen data datlen start = enable receiver to ssc_rhr to ssc_rhr rd ssc_imr pdc interrupt control ssc interrupt set rxrdy ovrun rxsync receiver transmitter txrdy txempty txsync txbufe endtx rxbuff endrx clear ssc_ier ssc_idr
677 6438fCatarmC21-jun-10 at91sam9g45 figure 34-18. interrupt block diagram ssc_imr interrupt control ssc interrupt set rxrdy ovrun rxsync receiver transmitter txrdy txempty txsync clear ssc_ier ssc_idr
678 6438fCatarmC21-jun-10 at91sam9g45 34.8 ssc application examples the ssc can support several serial communica tion modes used in audio or high speed serial links. some standard applications are shown in t he following figures. all se rial link applications supported by the ssc are not listed here. figure 34-19. audio application block diagram figure 34-20. codec application block diagram ssc rk rf rd td tf tk clock sck word select ws data sd i2s receiver clock sck word select ws data sd right channel left channel msb msb lsb ssc rk rf rd td tf tk serial data clock (sclk) frame sync (fsync) serial data out serial data in codec serial data clock (sclk) frame sync (fsync) serial data out serial data in first time slot dstart dend
679 6438fCatarmC21-jun-10 at91sam9g45 figure 34-21. time slot application block diagram ssc rk rf rd td tf tk sclk fsync data out data in codec first time slot serial data clock (sclk) frame sync (fsync) serial data out serial data in codec second time slot first time slot second time slot dstart dend
680 6438fCatarmC21-jun-10 at91sam9g45 34.9 synchronous serial contro ller (ssc) user interface table 34-6. register mapping offset register name access reset 0x0 control register ssc_cr write-only C 0x4 clock mode register ssc_cmr read-write 0x0 0x8 reserved C C C 0xc reserved C C C 0x10 receive clock mode register ssc_rcmr read-write 0x0 0x14 receive frame mode register ssc_rfmr read-write 0x0 0x18 transmit clock mode register ssc_tcmr read-write 0x0 0x1c transmit frame mode register ssc_tfmr read-write 0x0 0x20 receive holding register ssc_rhr read-only 0x0 0x24 transmit holding register ssc_thr write-only C 0x28 reserved C C C 0x2c reserved C C C 0x30 receive sync. holding register ssc_rshr read-only 0x0 0x34 transmit sync. holding register ssc_tshr read-write 0x0 0x38 receive compare 0 register ssc_rc0r read-write 0x0 0x3c receive compare 1 register ssc_rc1r read-write 0x0 0x40 status register ssc_sr read-only 0x000000cc 0x44 interrupt enable register ssc_ier write-only C 0x48 interrupt disable register ssc_idr write-only C 0x4c interrupt mask register ssc_imr read-only 0x0 0x50-0xfc reserved C C C 0x100- 0x124 reserved for peripheral data controller (pdc) C C C
681 6438fCatarmC21-jun-10 at91sam9g45 34.9.1 ssc control register name: ssc_cr: addresses: 0xfff9c000 (0), 0xfffa0000 (1) access: write-only ? rxen: receive enable 0 = no effect. 1 = enables receive if rxdis is not set. ? rxdis: receive disable 0 = no effect. 1 = disables receive. if a character is currently being re ceived, disables at end of current character reception. ? txen: transmit enable 0 = no effect. 1 = enables transmit if txdis is not set. ? txdis: transmit disable 0 = no effect. 1 = disables transmit. if a character is currently being trans mitted, disables at end of current character transmission. ? swrst: software reset 0 = no effect. 1 = performs a software reset. has priority on any other bit in ssc_cr. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 swrstCCCCCtxdistxen 76543210 CCCCCCrxdisrxen
682 6438fCatarmC21-jun-10 at91sam9g45 34.9.2 ssc clock mode register name: ssc_cmr addresses: 0xfff9c004 (0), 0xfffa0004 (1) access: read-write ? div: clock divider 0 = the clock divider is not active. any other value: the divided clock equals the master clock divided by 2 times div. the maximum bit rate is mck/2. the minimum bit rate is mck/2 x 4095 = mck/8190. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCC div 76543210 div
683 6438fCatarmC21-jun-10 at91sam9g45 34.9.3 ssc receive clock mode register name: ssc_rcmr addresses: 0xfff9c010 (0), 0xfffa0010 (1) access: read-write ? cks: receive clock selection ? cko: receive clock output mode selection ? cki: receive clock inversion 0 = the data inputs (data and frame sync signals) are sampled on receive clock falling edge. the frame sync signal output is shifted out on receive clock rising edge. 1 = the data inputs (data and frame sync signals) are samp led on receive clock rising edge. the frame sync signal out- put is shifted out on receive clock falling edge. cki affects only the receive clock and not the output clock signal. 31 30 29 28 27 26 25 24 period 23 22 21 20 19 18 17 16 sttdly 15 14 13 12 11 10 9 8 C C C stop start 76543210 ckg cki cko cks cks selected receive clock 0x0 divided clock 0x1 tk clock signal 0x2 rk pin 0x3 reserved cko receive clock output mode rk pin 0x0 none input-only 0x1 continuous receive clock output 0x2 receive clock only during data transfers output 0x3-0x7 reserved
684 6438fCatarmC21-jun-10 at91sam9g45 ? ckg: receive clock gating selection ? start: receive start selection ? stop: receive stop selection 0 = after completion of a data transfer when starting with a compare 0, the receiver stops the data transfer and waits for a new compare 0. 1 = after starting a receive with a compare 0, the receiver operates in a continuous mode until a compare 1 is detected. ? sttdly: receive start delay if sttdly is not 0, a delay of sttdly clock cycles is inserted between the start event and the actual start of reception. when the receiver is programmed to start synchronously with the transmitter, the delay is also applied. note: it is very important that sttdly be set carefully. if sttdly must be set, it should be done in relation to tag (receive sync data) reception. ? period: receive period divider selection this field selects the divider to apply to the selected receive clock in order to generate a new frame sync signal. if 0, no period signal is generated. if not 0, a period sig nal is generated each 2 x (period+1) receive clock. ckg receive clock gating 0x0 none, continuous clock 0x1 receive clock enabled only if rf low 0x2 receive clock enabled only if rf high 0x3 reserved start receive start 0x0 continuous, as soon as the receiver is enabled, and immediately after the end of transfer of the previous data. 0x1 transmit start 0x2 detection of a low level on rf signal 0x3 detection of a high level on rf signal 0x4 detection of a falling edge on rf signal 0x5 detection of a rising edge on rf signal 0x6 detection of any level change on rf signal 0x7 detection of any edge on rf signal 0x8 compare 0 0x9-0xf reserved
685 6438fCatarmC21-jun-10 at91sam9g45 34.9.4 ssc receive frame mode register name: ssc_rfmr addresses: 0xfff9c014 (0), 0xfffa0014 (1) access: read-write ? datlen: data length 0 = forbidden value (1-bit data length not supported). any other value: the bit stream contains datlen + 1 data bits. moreover, it defines the transfer size performed by the pdc assigned to the receiver. if datlen is lower or equal to 7, data transfers are in bytes. if datlen is between 8 and 15 (included), half-words are transferred, and for any other value, 32-bit words are transferred. ? loop: loop mode 0 = normal operating mode. 1 = rd is driven by td, rf is driven by tf and tk drives rk. ? msbf: most significant bit first 0 = the lowest significant bit of the data register is sampled first in the bit stream. 1 = the most significant bit of the data register is sampled first in the bit stream. ? datnb: data number per frame this field defines the number of data words to be received after each transfer start, which is equal to (datnb + 1). ? fslen: receive frame sync length this field defines the number of bits sampled and stored in the receive sync data register. when this mode is selected by the start field in the receive clock mode register, it also determines the length of the sampled data to be compared to the compare 0 or compare 1 register. this field is used with fslen_ext to determine the pulse length of the receive frame sync signal. pulse length is equal to fslen + (fslen_ext * 16) + 1 receive clock periods. 31 30 29 28 27 26 25 24 fslen_ext fslen_ext fslen_ext fslen_ext CCCfsedge 23 22 21 20 19 18 17 16 C fsos fslen 15 14 13 12 11 10 9 8 CCC C datnb 765 4 3210 msbf C loop datlen
686 6438fCatarmC21-jun-10 at91sam9g45 ? fsos: receive frame sync output selection ? fsedge: frame sync edge detection determines which edge on frame sy nc will generate the in terrupt rxsyn in the ssc status register. ? fslen_ext: fslen field extension extends fslen field. for details, refer to fslen bit description on page 685 . fsos selected receive frame sync signal rf pin 0x0 none input-only 0x1 negative pulse output 0x2 positive pulse output 0x3 driven low during data transfer output 0x4 driven high during data transfer output 0x5 toggling at each start of data transfer output 0x6-0x7 reserved undefined fsedge frame sync edge detection 0x0 positive edge detection 0x1 negative edge detection
687 6438fCatarmC21-jun-10 at91sam9g45 34.9.5 ssc transmit clock mode register name: ssc_tcmr addresses: 0xfff9c018 (0), 0xfffa0018 (1) access: read-write ? cks: transmit clock selection ? cko: transmit clock output mode selection ? cki: transmit clock inversion 0 = the data outputs (data and frame sync signals) are shi fted out on transmit clock falling edge. the frame sync signal input is sampled on transmit clock rising edge. 1 = the data outputs (data and frame sync signals) are shifte d out on transmit clock rising edge. the frame sync signal input is sampled on tran smit clock falling edge. cki affects only the transmit clock and not the output clock signal. 31 30 29 28 27 26 25 24 period 23 22 21 20 19 18 17 16 sttdly 15 14 13 12 11 10 9 8 CCCC start 76543210 ckg cki cko cks cks selected transmit clock 0x0 divided clock 0x1 rk clock signal 0x2 tk pin 0x3 reserved cko transmit clock output mode tk pin 0x0 none input-only 0x1 continuous transmit clock output 0x2 transmit clock only during data transfers output 0x3-0x7 reserved
688 6438fCatarmC21-jun-10 at91sam9g45 ? ckg: transmit clock gating selection ? start: transmit start selection ? sttdly: transmit start delay if sttdly is not 0, a delay of sttdly clock cycles is inse rted between the start event and the actual start of transmission of data. when the transmitter is programmed to start sync hronously with the receiver, the delay is also applied. note: sttdly must be set carefully. if sttdly is too short in respect to tag (transmit sync data) emission, data is emit- ted instead of the end of tag. ? period: transmit period divider selection this field selects the divider to apply to the selected transmi t clock to generate a new frame sync signal. if 0, no period signal is generated. if not 0, a period signal is generated at each 2 x (period+1) transmit clock. ckg transmit clock gating 0x0 none, continuous clock 0x1 transmit clock enabled only if tf low 0x2 transmit clock enabled only if tf high 0x3 reserved start transmit start 0x0 continuous, as soon as a word is written in the ssc_thr register (if transmit is enabled), and immediately after the end of transfer of the previous data. 0x1 receive start 0x2 detection of a low level on tf signal 0x3 detection of a high level on tf signal 0x4 detection of a falling edge on tf signal 0x5 detection of a rising edge on tf signal 0x6 detection of any level change on tf signal 0x7 detection of any edge on tf signal 0x8 - 0xf reserved
689 6438fCatarmC21-jun-10 at91sam9g45 34.9.6 ssc transmit frame mode register name: ssc_tfmr addresses: 0xfff9c01c (0), 0xfffa001c (1) access: read-write ? datlen: data length 0 = forbidden value (1-bit data length not supported). any other value: the bit stream contains datlen + 1 data bits. moreover, it defines the transfer size performed by the pdc assigned to the transmit. if datlen is lower or equal to 7, data transfers are bytes, if datlen is between 8 and 15 (included), half-words are transferred, and for any other value, 32-bit words are transferred. ? datdef: data default value this bit defines the level driven on the td pin while out of tran smission. note that if the pin is defined as multi-drive by th e pio controller, the pin is enabled only if the scc td output is 1. ? msbf: most significant bit first 0 = the lowest significant bit of the data register is shifted out first in the bit stream. 1 = the most significant bit of the data register is shifted out first in the bit stream. ? datnb: data number per frame this field defines the number of data words to be transferred after each transfer start, which is equal to (datnb +1). ? fslen: transmit frame syn length this field defines the length of the transmit frame sync sig nal and the number of bits shifted out from the transmit sync data register if fsden is 1. this field is used with fslen_ext to determine the pulse length of the transmit frame sync signal. pulse length is equal to fslen + (fslen_ext * 16) + 1 transmit clock period. 31 30 29 28 27 26 25 24 fslen_ext fslen_ext fslen_ext fslen_ext CCCfsedge 23 22 21 20 19 18 17 16 fsden fsos fslen 15 14 13 12 11 10 9 8 CCC C datnb 765 4 3210 m s b f C dat d e f dat l e n
690 6438fCatarmC21-jun-10 at91sam9g45 ? fsos: transmit frame sync output selection ? fsden: frame sync data enable 0 = the td line is driven with the default value during the transmit frame sync signal. 1 = ssc_tshr value is shifted out during the transmission of the transmit frame sync signal. ? fsedge: frame sync edge detection determines which edge on frame sync will gene rate the interrupt tx syn (status register). ? fslen_ext: fslen field extension extends fslen field. for details, refer to fslen bit description on page 689 . fsos selected transmit frame sync signal tf pin 0x0 none input-only 0x1 negative pulse output 0x2 positive pulse output 0x3 driven low during data transfer output 0x4 driven high during data transfer output 0x5 toggling at each start of data transfer output 0x6-0x7 reserved undefined fsedge frame sync edge detection 0x0 positive edge detection 0x1 negative edge detection
691 6438fCatarmC21-jun-10 at91sam9g45 34.9.7 ssc receive holding register name: ssc_rhr addresses: 0xfff9c020 (0), 0xfffa0020 (1) access: read-only ? rdat: receive data right aligned regardless of the number of data bits defined by datlen in ssc_rfmr. 34.9.8 ssc transmit holding register name: ssc_thr addresses: 0xfff9c024 (0), 0xfffa0024 (1) access: write-only ? tdat: transmit data right aligned regardless of the number of data bits defined by datlen in ssc_tfmr. 31 30 29 28 27 26 25 24 rdat 23 22 21 20 19 18 17 16 rdat 15 14 13 12 11 10 9 8 rdat 76543210 rdat 31 30 29 28 27 26 25 24 tdat 23 22 21 20 19 18 17 16 tdat 15 14 13 12 11 10 9 8 tdat 76543210 tdat
692 6438fCatarmC21-jun-10 at91sam9g45 34.9.9 ssc receive synchronization holding register name: ssc_rshr addresses: 0xfff9c030 (0), 0xfffa0030 (1) access: read-only ? rsdat: receive synchronization data 34.9.10 ssc transmit synchronization holding register name: ssc_tshr addresses: 0xfff9c034 (0), 0xfffa0034 (1) access: read-write ? tsdat: transmit synchronization data 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 rsdat 76543210 rsdat 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 tsdat 76543210 tsdat
693 6438fCatarmC21-jun-10 at91sam9g45 34.9.11 ssc receive compare 0 register name: ssc_rc0r addresses: 0xfff9c038 (0), 0xfffa0038 (1) access: read-write ? cp0: receive compare data 0 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 cp0 76543210 cp0
694 6438fCatarmC21-jun-10 at91sam9g45 34.9.12 ssc receive compare 1 register name: ssc_rc1r addresses: 0xfff9c03c (0), 0xfffa003c (1) access: read-write ? cp1: receive compare data 1 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 cp1 76543210 cp1
695 6438fCatarmC21-jun-10 at91sam9g45 34.9.13 ssc status register name: ssc_sr addresses: 0xfff9c040 (0), 0xfffa0040 (1) access: read-only ? txrdy: transmit ready 0 = data has been loaded in ssc_thr and is waiting to be loaded in the transmit shift register (tsr). 1 = ssc_thr is empty. ? txempty: transmit empty 0 = data remains in ssc_thr or is currently transmitted from tsr. 1 = last data written in ssc_thr has been loaded in tsr and last data loaded in tsr has been transmitted. ? endtx: end of transmission 0 = the register ssc_tcr has not reached 0 since the last write in ssc_tcr or ssc_tncr. 1 = the register ssc_tcr has reached 0 si nce the last write in ssc_tcr or ssc_tncr. ? txbufe: transmit buffer empty 0 = ssc_tcr or ssc_tncr have a value other than 0. 1 = both ssc_tcr and ssc_tncr have a value of 0. ? rxrdy: receive ready 0 = ssc_rhr is empty. 1 = data has been receiv ed and loaded in ssc_rhr. ? ovrun: receive overrun 0 = no data has been loaded in ssc_rhr while previous data has not been read since the last read of the status register. 1 = data has been loaded in ssc_rhr while previous data has not yet been read since the last read of the status register. ? endrx: end of reception 0 = data is written on the receive counter register or receive next counter register. 1 = end of pdcdmac transfer when receive counter register has arrived at zero. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCrxentxen 15 14 13 12 11 10 9 8 CCCCrxsynt xsyn cp1 cp0 76543210 rxbuff endrx ovrun rxrdy txbufe endtx txempty txrdy
696 6438fCatarmC21-jun-10 at91sam9g45 ? rxbuff: receive buffer full 0 = ssc_rcr or ssc_rncr have a value other than 0. 1 = both ssc_rcr and ssc_rncr have a value of 0. ?cp0: compare 0 0 = a compare 0 has not occurred since the last read of the status register. 1 = a compare 0 has occurred since the last read of the status register. ?cp1: compare 1 0 = a compare 1 has not occurred since the last read of the status register. 1 = a compare 1 has occurred since the last read of the status register. ? txsyn: transmit sync 0 = a tx sync has not occurred since the last read of the status register. 1 = a tx sync has occurred since the last read of the status register. ? rxsyn: receive sync 0 = an rx sync has not occurred since the last read of the status register. 1 = an rx sync has occurred since the last read of the status register. ? txen: transmit enable 0 = transmit is disabled. 1 = transmit is enabled. ? rxen: receive enable 0 = receive is disabled. 1 = receive is enabled.
697 6438fCatarmC21-jun-10 at91sam9g45 34.9.14 ssc interrupt enable register name: ssc_ier addresses: 0xfff9c044 (0), 0xfffa0044 (1) access: write-only ? txrdy: transmit ready interrupt enable 0 = 0 = no effect. 1 = enables the transmit ready interrupt. ? txempty: transmit empty interrupt enable 0 = no effect. 1 = enables the transmit empty interrupt. ? endtx: end of transmission interrupt enable 0 = no effect. 1 = enables the end of transmission interrupt. ? txbufe: transmit buffer empty interrupt enable 0 = no effect. 1 = enables the transmit buffer empty interrupt ? rxrdy: receive ready interrupt enable 0 = no effect. 1 = enables the receive ready interrupt. ? ovrun: receive overrun interrupt enable 0 = no effect. 1 = enables the receive overrun interrupt. ? endrx: end of reception interrupt enable 0 = no effect. 1 = enables the end of reception interrupt. ? rxbuff: receive buffer full interrupt enable 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCrxsynt xsyn cp1 cp0 76543210 rxbuff endrx ovrun rxrdy txbufe endtx txempty txrdy
698 6438fCatarmC21-jun-10 at91sam9g45 0 = no effect. 1 = enables the receive buffer full interrupt. ? cp0: compare 0 interrupt enable 0 = no effect. 1 = enables the compare 0 interrupt. ? cp1: compare 1 interrupt enable 0 = no effect. 1 = enables the compare 1 interrupt. ? txsyn: tx sync interrupt enable 0 = no effect. 1 = enables the tx sync interrupt. ? rxsyn: rx sync interrupt enable 0 = no effect. 1 = enables the rx sync interrupt.
699 6438fCatarmC21-jun-10 at91sam9g45 34.9.15 ssc interrupt disable register name: ssc_idr addresses: 0xfff9c048 (0), 0xfffa0048 (1) access: write-only ? txrdy: transmit ready interrupt disable 0 = no effect. 1 = disables the transmit ready interrupt. ? txempty: transmit empty interrupt disable 0 = no effect. 1 = disables the transmit empty interrupt. ? endtx: end of transmission interrupt disable 0 = no effect. 1 = disables the end of transmission interrupt. ? txbufe: transmit buffer empty interrupt disable 0 = no effect. 1 = disables the transmit buffer empty interrupt. ? rxrdy: receive ready interrupt disable 0 = no effect. 1 = disables the receive ready interrupt. ? ovrun: receive overrun interrupt disable 0 = no effect. 1 = disables the receive overrun interrupt. ? endrx: end of reception interrupt disable 0 = no effect. 1 = disables the end of reception interrupt. ? rxbuff: receive buffer full interrupt disable 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCrxsynt xsyn cp1 cp0 76543210 rxbuff endrx ovrun rxrdy txbufe endtx txempty txrdy
700 6438fCatarmC21-jun-10 at91sam9g45 0 = no effect. 1 = disables the receive buffer full interrupt. ? cp0: compare 0 interrupt disable 0 = no effect. 1 = disables the compare 0 interrupt. ? cp1: compare 1 interrupt disable 0 = no effect. 1 = disables the compare 1 interrupt. ? txsyn: tx sync interrupt enable 0 = no effect. 1 = disables the tx sync interrupt. ? rxsyn: rx sync interrupt enable 0 = no effect. 1 = disables the rx sync interrupt.
701 6438fCatarmC21-jun-10 at91sam9g45 34.9.16 ssc interrupt mask register name: ssc_imr addresses: 0xfff9c04c (0), 0xfffa004c (1) access: read-only ? txrdy: transmit ready interrupt mask 0 = the transmit ready interrupt is disabled. 1 = the transmit ready interrupt is enabled. ? txempty: transmit empty interrupt mask 0 = the transmit empty interrupt is disabled. 1 = the transmit empty interrupt is enabled. ? endtx: end of transmission interrupt mask 0 = the end of transmission interrupt is disabled. 1 = the end of transmission interrupt is enabled. ? txbufe: transmit buffer empty interrupt mask 0 = the transmit buffer empty interrupt is disabled. 1 = the transmit buffer empty interrupt is enabled. ? rxrdy: receive ready interrupt mask 0 = the receive ready interrupt is disabled. 1 = the receive ready interrupt is enabled. ? ovrun: receive overrun interrupt mask 0 = the receive overrun interrupt is disabled. 1 = the receive overrun interrupt is enabled. ? endrx: end of reception interrupt mask 0 = the end of reception interrupt is disabled. 1 = the end of reception interrupt is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCrxsynt xsyn cp1 cp0 76543210 rxbuff endrx ovrun rxrdy txbufe endtx txempty txrdy
702 6438fCatarmC21-jun-10 at91sam9g45 ? rxbuff: receive buffer full interrupt mask 0 = the receive buffer full interrupt is disabled. 1 = the receive buffer full interrupt is enabled. ? cp0: compare 0 interrupt mask 0 = the compare 0 interrupt is disabled. 1 = the compare 0 interrupt is enabled. ? cp1: compare 1 interrupt mask 0 = the compare 1 interrupt is disabled. 1 = the compare 1 interrupt is enabled. ? txsyn: tx sync interrupt mask 0 = the tx sync interrupt is disabled. 1 = the tx sync interrupt is enabled. ? rxsyn: rx sync interrupt mask 0 = the rx sync interrupt is disabled. 1 = the rx sync interrupt is enabled.
703 6438fCatarmC21-jun-10 at91sam9g45 35. ethernet mac 10/100 (emac) 35.1 description the emac module implements a 10/100 ethernet mac compatible with the ieee 802.3 stan- dard using an address checker, statistics and co ntrol registers, receive and transmit blocks, and a dma interface. the address checker recognizes four specific 48-bit addresses and contains a 64-bit hash regis- ter for matching multicast and unicast addresses. it can recognize the broadcast address of all ones, copy all frames, and act on an external address match signal. the statistics register block contains register s for counting various ty pes of event associated with transmit and receive operations. these register s, along with the status words stored in the receive buffer list, enable software to generate network management statistics compatible with ieee 802.3. 35.2 embedded characteristics ? compatibility with ieee standard 802.3 ? 10 and 100 mbits per second data through put capability ? full- and half-duplex operations ? mii or rmii interface to the physical layer ? register interface to address, data, status and control registers ? dma interface, operating as a master on the memory controller ? interrupt generation to signal receive and transmit completion ? 128-byte transmit and 128-byte receive fifos ? automatic pad and crc generation on transmitted frames ? address checking logic to recognize four 48-bit addresses ? supports promiscuous mode where all valid frames are copied to memory ? supports physical layer management through mdio interface ? supports wake-on-lan. the receiver supports wake-on-lan by detecting the following events on incoming receive frames: C magic packet C arp request to the device ip address C specific address 1 filter match C multicast hash filter match
704 6438fCatarmC21-jun-10 at91sam9g45 35.3 block diagram figure 35-1. emac block diagram apb slave register interface dma interface address checker statistics registers control registers ethernet receive ethernet transmit mdio mii/rmii rx fifo tx fifo ahb master
705 6438fCatarmC21-jun-10 at91sam9g45 35.4 functional description the macb has several clock domains: ? system bus clock (ahb and apb): dma and register blocks ? transmit clock: transmit block ? receive clock: receive and address checker block the system bus clock must run at least as fast as the receive clock and transmit clock (25 mhz at 100 mbps, and 2.5 mhz at 10 mbps). figure 35-1 illustrates the different blocks of the emac module. the control registers drive the mdio interface, setup up dma activity, start frame transmission and select modes of operation such as full- or half-duplex. the receive block checks for valid preamble, fcs, alignment and length, and presents received frames to the address checking block and dma interface. the transmit block takes data from the dma interface, adds preamble and, if necessary, pad and fcs, and transmits data according to the csma/cd (carrier sense multiple access with col- lision detect) protocol. the start of transmission is deferred if crs (carrier sense) is active. if col (collision) becomes active during transmission, a jam se quence is asserted and the transmission is retried after a random back off. crs and col have no effect in full duplex mode. the dma block connects to external memory thro ugh its ahb bus interface. it contains receive and transmit fifos for buffering frame data. it loads the transmit fifo and empties the receive fifo using ahb bus master operations. receive da ta is not sent to memory until the address checking logic has determined that the frame should be copied. receive or transmit frames are stored in one or more buffers. receive buffers have a fixed length of 128 bytes. transmit buffers range in length between 0 and 2047 bytes, and up to 128 buffers are permitted per frame. the dma block manages the transmit and receive framebuffer queues. these queues can hold mul- tiple frames. 35.4.1 clock synchronization module in the emac requires that the bus clock (hclk) runs at the speed of the macb_tx/rx_clk at least, which is 25 mhz at 100 mbps, and 2.5 mhz at 10 mbps. 35.4.2 memory interface frame data is transferred to and from the emac through the dma interface. all transfers are 32- bit words and may be single accesses or bursts of 2, 3 or 4 words. burst accesses do not cross sixteen-byte boundaries. bursts of 4 words are the default data transfer; single accesses or bursts of less than four words may be used to transfer data at the beginning or the end of a buffer. the dma controller performs six types of operation on the bus. in order of priority, these are: 1. receive buffer manager write 2. receive buffer manager read 3. transmit data dma read 4. receive data dma write 5. transmit buffer manager read 6. transmit buffer manager write
706 6438fCatarmC21-jun-10 at91sam9g45 35.4.2.1 fifo the fifo depths are 1 28 bytes for receive and 1 28 bytes for transmit and are a function of the system clock speed, memory latency and network speed. data is typically transferred into and out of the fifos in bursts of four words. for receive, a bus request is asserted when the fifo contains f our words and has space for 28 more. for transmit, a bus request is generated when there is space for four words, or when there is space for 27 words if the next transfer is to be only one or two words. thus the bus latency must be less than the time it takes to load the fifo and transmit or receive three words (112 bytes) of data. at 100 mbit/s, it takes 8960 ns to transmit or receive 112 bytes of data. in addition, six master clock cycles should be allowed for data to be loaded from the bus and to propagate through the fifos. for a 133 mhz master clock this takes 45 ns, making the bus latency requirement 8915 ns. 35.4.2.2 receive buffers received frames, including crc/fc s optionally, are written to receive buffers stored in mem- ory. each receive buffer is 128 bytes long. the start location for each receive buffer is stored in memory in a list of receive buffer descriptors at a location pointed to by the receive buffer queue pointer register. the receive buffer start location is a word address. for the first buffer of a frame, the start location can be offset by up to three bytes depending on the value written to bits 14 and 15 of the network configuration register. if the start location of the buffer is offset the available length of the first buffer of a frame is reduced by the corresponding number of bytes. each list entry consists of two words, the first being the address of the receive buffer and the second being the receive status. if the length of a receive frame exceeds the buffer length, the status word for the used buffer is written with zer oes except for the start of frame bit and the offset bits, if appropriate. bit zero of the address field is written to one to show the buffer has been used. the receive buffer manager then reads the location of the next receive buffer and fills that with receive frame data. the final buff er descriptor status word contains the complete frame status. refer to table 35-1 for details of the receive buffer descriptor list. table 35-1. receive buffer descriptor entry bit function word 0 31:2 address of beginning of buffer 1 wrap - marks last descriptor in receive buffer descriptor list. 0 ownership - needs to be zero for the emac to write data to the receive buffer. the emac sets this to one once it has successfully written a frame to memory. software has to clear this bit before the buffer can be used again. word 1 31 global all ones broadcast address detected 30 multicast hash match 29 unicast hash match 28 external address match 27 reserved for future use
707 6438fCatarmC21-jun-10 at91sam9g45 to receive frames, the buffer descriptors must be initialized by writing an appropriate address to bits 31 to 2 in the first word of each list entry. bit zero must be written with zero. bit one is the wrap bit and indicates the last entry in the list. the start location of the receive buffer descriptor list must be written to the receive buffer queue pointer register before setting the receive enable bit in the network control register to enable receive. as soon as the receive block starts writing received frame data to the receive fifo, the receive buffer manager reads the first receive buffer location pointed to by the receive buffer queue pointer register. if the filter block then indicates that the frame should be copied to memory, the receive data dma operation starts writing data into the receive buffer. if an error occurs, the buffer is recov- ered. if the current buffer pointer has its wrap bit set or is the 1024 th descriptor, the next receive buffer location is read from the beginning of the receive descriptor list. otherwise, the next receive buffer location is read from the next word in memory. there is an 11-bit counter to count out the 2048 word locations of a maximum length, receive buffer descriptor list. this is added with the valu e originally written to the receive buffer queue pointer register to produce a pointer into the list. a read of the receive buffer queue pointer reg- ister returns the pointer value, which is the queue entry currently being accessed. the counter is reset after receive status is written to a descript or that has its wrap bit set or rolls over to zero after 1024 descriptors have been accessed. the value written to the receive buffer pointer regis- ter may be any word-aligned address, provided that there are at least 2048 word locations available between the pointer and the top of the memory. section 3.6 of the amba 2.0 specification states that bursts should not cross 1k boundaries. as receive buffer manager writes are bursts of two words, to ensure that this does not occur, it is 26 specific address register 1 match 25 specific address register 2 match 24 specific address register 3 match 23 specific address register 4 match 22 type id match 21 vlan tag detected (i.e., type id of 0x8100) 20 priority tag detected (i.e., type id of 0x8100 and null vlan identifier) 19:17 vlan priority (only valid if bit 21 is set) 16 concatenation format indicator (cfi) bit (only valid if bit 21 is set) 15 end of frame - when set the buffer contains the end of a frame. if end of frame is no t set, then the only other valid status are bits 12, 13 and 14. 14 start of frame - when set the buffer contains the start of a frame. if both bits 15 a nd 14 are set, then the buffer contains a whole frame. 13:12 receive buffer offset - indicates the number of bytes by which the data in the first buffer is offset from the word address. updated with the current values of the network configuration register. if jum bo frame mode is enabled through bit 3 of the network configuration register, then bits 13: 12 of the receive buffer descriptor entry are used to indicate bits 13:12 of the frame length. 11:0 length of frame including fcs (if selected). bits 13:12 are also used if jumbo frame mode is selected. table 35-1. receive buffer descrip tor entry (continued) bit function
708 6438fCatarmC21-jun-10 at91sam9g45 best to write the pointer register with the least three significant bits set to zero. as receive buffers are used, the receive buffer manager sets bit zero of the first word of the descriptor to indicate used . if a receive error is detected the receive buffer currently being written is recovered. previ- ous buffers are not recovered. software should search through the used bits in the buffer descriptors to find out how many frames have been received. it should be checking the start-of- frame and end-of-frame bits, and not rely on the value returned by the receive buffer queue pointer register which changes contin uously as more buffers are used. for crc errored frames, excessive length frames or length field mismatched frames, all of which are counted in the statistics registers, it is possible that a frame fragment might be stored in a sequence of receive buffers. software can detect this by looking for start of frame bit set in a buffer following a buffer with no end of frame bit set. for a properly working ethernet system, there should be no excessively long frames or frames greater than 128 bytes with crc/ fcs errors. collision fragments are less than 128 bytes long. therefore, it is a rare occurrence to find a frame fragment in a receive buffer. if bit zero is set when the receive buffer manager reads the location of the receive buffer, then the buffer has already been used and cannot be used again until software has processed the frame and cleared bit zero. in this case, the dma block sets the buffer not available bit in the receive status register and triggers an interrupt. if bit zero is set when the receive buffer manager reads the location of the receive buffer and a frame is being received, the frame is discarded and the receive resource error statistics register is incremented. a receive overrun condition occurs when bus was not granted in time or because hresp was not ok (bus error). in a receive overrun conditi on, the receive overrun interrupt is asserted and the buffer currently being written is recovered. the next frame received with an address that is recognized reuses the buffer. if bit 17 of the network configuration register is set, the fcs of received frames shall not be cop- ied to memory. the frame length indicated in the receive status field shall be reduced by four bytes in this case. 35.4.2.3 transmit buffer frames to be transmitted are stored in one or more transmit buffers. transmit buffers can be between 0 and 2047 bytes long, so it is possible to transmit frames longer than the maximum length specified in ieee standard 802.3. zero length buffers are allowed. the maximum number of buffers permitted for each transmit frame is 128. the start location for each transmit buffer is stored in memory in a list of transmit buffer descrip- tors at a location pointed to by the transmit buffer queue pointer register. each list entry consists of two words, the first being the byte address of the transmit buffer and the second containing the transmit control and status. frames can be transmitted with or without automatic crc gen- eration. if crc is automatically generated, pad is also automatically generated to take frames to a minimum length of 64 bytes. table 35-2 on page 709 defines an entry in the transmit buffer descriptor list. to transmit frames, the buffer descriptors must be initialized by writing an appro- priate byte address to bits 31 to 0 in the first word of each list entry. the second transmit buffer descriptor is initialized with control information that indicates the length of the buffer, whether or not it is to be transmitted wit h crc and whether the bu ffer is the last bu ffer in the frame. after transmission, the control bits are written back to the second word of the first buffer along with the used bit and other status information. bit 31 is the used bit which must be zero when
709 6438fCatarmC21-jun-10 at91sam9g45 the control word is read if transmission is to happen. it is written to one when a frame has been transmitted. bits 27, 28 and 29 indicate various transmit error conditions. bit 30 is the wrap bit which can be set for any buffer within a frame. if no wrap bit is encountered after 1024 descrip- tors, the queue pointer rolls over to the start in a similar fashion to the receive queue. the transmit buffer queue pointer register must not be written while transmit is active. if a new value is written to the transmit buffer queue pointer register, the queue pointer resets itself to point to the beginning of the new queue. if transmit is disabled by writing to bit 3 of the network control, the transmit buffer queue pointer register resets to point to the beginning of the transmit queue. note that disabling receive does not have the same effect on the receive queue pointer. once the transmit queue is init ialized, transmit is activate d by writing to bit 9, the transmit start bit of the network control register. transmit is halted when a buffer descriptor with its used bit set is read, or if a transmit error occurs, or by writ ing to the transmit halt bit of the network control register. (transmission is suspended if a pause frame is received while the pause enable bit is set in the network configuration register.) rewrit ing the start bit while transmission is active is allowed. transmission control is implemented with a tx_go variable which is readable in the transmit sta- tus register at bit location 3. the tx_go variable is reset when: C transmit is disabled C a buffer descriptor with its ownership bit set is read C a new value is written to the transmit buffer queue pointer register C bit 10, tx_halt, of the network control register is written C there is a transmit error such as too many retries or a transmit underrun. to set tx_go, write to bit 9, tx_start, of the network control register. transmit halt does not take effect until any ongoing transmit finishes. if a collision occurs du ring transmission of a multi-buf- fer frame, transmission automatically restarts from the first buffer of the frame. if a used bit is read midway through transmission of a multi-buffer frame, this is treated as a transmit error. transmission stops, tx_er is asserted and the fcs is bad. if transmission stops due to a transmit error, the transmit queue pointer resets to point to the beginning of the transmit queue. software needs to re-initialize the transmit queue after a trans- mit error. if transmission stops due to a used bit being read at the start of the frame, the transmission queue pointer is not reset and transmit starts from the same transmit buffer descriptor when the transmit start bit is written table 35-2. transmit buffer descriptor entry bit function word 0 31:0 byte address of buffer word 1 31 used. needs to be zero for the emac to read data from the tran smit buffer. the emac sets this to one for the first buffer of a frame once it has been successfully transmitted. software has to clear this bit before the buffer can be used again. note: this bit is only set for the first buffer in a frame unlike receive where all buffers have the used bit set once used. 30 wrap. marks last descriptor in transmit buffer descriptor list.
710 6438fCatarmC21-jun-10 at91sam9g45 35.4.3 transmit block this block transmits frames in accordance wi th the ethernet ieee 802.3 csma/cd protocol. frame assembly starts by adding preamble and the start frame delimiter. data is taken from the transmit fifo a word at a time. data is transmi tted least significant nibble first. if necessary, padding is added to increase the frame length to 60 bytes. crc is calculated as a 32-bit polyno- mial. this is inverted and appended to the end of the frame, taking the frame length to a minimum of 64 bytes. if the no crc bit is set in the second word of the last buffer descriptor of a transmit frame, neither pad nor crc are appended. in full-duplex mode, frames are transmitted immediately. back-to-back frames are transmitted at least 96 bit times apart to guarantee the interframe gap. in half-duplex mode, the transmitter checks carrier sense. if asserted, it waits for it to de-assert and then starts transmission afte r the interframe gap of 96 bit times. if the collision signal is asserted during transmission, the transmitter transmits a jam sequence of 32 bits taken from the data register and then retry transmission after the back off time has elapsed. the back-off time is based on an xor of the 10 least significant bits of the data coming from the transmit fifo and a 10-bit pseudo random number generator. the number of bits used depends on the number of collisions seen . after the first collisi on, 1 bit is used, afte r the second 2, and so on up to 10. above 10, all 10 bits are used. an error is indicated and no further attempts are made if 16 attempts cause collisions. if transmit dma underruns, bad crc is automa tically appended using the same mechanism as jam insertion and the tx_er signal is asserted. for a properly configured system, this should never happen. if the back pressure bit is set in the network control register in half duplex mode, the transmit block transmits 64 bits of data, which can consist of 16 nibbles of 1011 or in bit-rate mode 64 1s, whenever it sees an incoming frame to force a collision. this provides a way of implementing flow control in half-duplex mode. 29 retry limit exceeded, transmit error detected 28 transmit underrun, occurs either when hresp is not ok (bus error) or the transmit data could not be fetched in time or when buffers are exhausted in mid frame. 27 buffers exhausted in mid frame 26:17 reserved 16 no crc. when set, no crc is appended to the current frame. this bit only needs to be set for the last buffer of a frame. 15 last buffer. when set, this bit indicates the last buffer in the current frame has been reached. 14:11 reserved 10:0 length of buffer table 35-2. transmit buffer descriptor entry bit function
711 6438fCatarmC21-jun-10 at91sam9g45 35.4.4 pause frame support the start of an 802.3 pause frame is as follows: the network configuration register contains a receive pause enable bit (13). if a valid pause frame is received, the pause time register is updated with the frames pause time, regardless of its current contents and regardless of the state of the configuration register bit 13. an interrupt (12) is triggered when a pause frame is received, assuming it is enabled in the interrupt mask register. if bit 13 is set in the network configuration register and the value of the pause time reg- ister is non-zero, no new frame is transmitted until the pause time register has decremented to zero. the loading of a new pause time, and hence the pausing of transmission, only occurs when the emac is configured for full-duplex operation. if the emac is configured for half-duplex, there is no transmission pause, but the pause frame received interrupt is st ill triggered. a valid pause frame is defined as having a destin ation address that matches either the address stored in specific address register 1 or matches 0x0180c2000001 and has the mac control frame type id of 0x8808 and the pause opcode of 0x0001. pause frames that have fcs or other errors are treated as invalid and are discarded. valid pause frames received increment the pause frame received statistic register. the pause time register decrements every 512 bit times (i.e., 128 rx_clks in nibble mode) once transmission has stopped. for test purposes, the register decrements every rx_clk cycle once transmission has stopped if bit 12 (retry test) is set in the network configuration register. if the pause enable bit (13) is not set in the network configuration register, then the decrementing occurs regardless of whether transmission has stopped or not. an interrupt (13) is asserted whenever the pause time register decrements to zero (assuming it is enabled in the inte rrupt mask register). 35.4.5 receive block the receive block checks for valid preamble, fcs, alignment and length, presents received frames to the dma block and stores the frames destination address for use by the address checking block. if, during frame reception, the frame is found to be too long or rx_er is asserted, a bad frame indication is sent to the dma bl ock. the dma block then ceases sending data to memory. at the end of frame reception, the receive block indicates to the dma block whether the frame is good or bad. the dma block recovers the current receive buffer if the frame was bad. the receive block signals the register block to increment the alignment error, the crc (fcs) error, the short frame, long frame, jabber error, the receive symbol error statistics and the length field mismatch statistics. the enable bit for jumbo frames in the network configuration register allows the emac to receive jumbo frames of up to 10240 bytes in size. this operation does not form part of the ieee802.3 specification and is disabled by default. when ju mbo frames are enabled, frames received with a frame size greater than 10240 bytes are discarded. table 35-3. start of an 802.3 pause frame destination address source address type (mac control frame) pause opcode pause time 0x0180c2000001 6 bytes 0x8808 0x0001 2 bytes
712 6438fCatarmC21-jun-10 at91sam9g45 35.4.6 address checking block the address checking (or filter) block indicates to the dma block which receive frames should be copied to memory. whether a frame is copied depends on what is enabled in the network configuration register, the state of the external match pin, the contents of the specific address and hash registers and the frames destination add ress. in this implementation of the emac, the frames source address is not checked. provided that bit 18 of the network configuration regis- ter is not set, a frame is not copied to memory if the emac is transmitting in half duplex mode at the time a destination address is received. if bit 18 of the network configuration register is set, frames can be received while transmitting in half-duplex mode. ethernet frames are transmitted a byte at a time, least significant bit first. the first six bytes (48 bits) of an ethernet frame make up the destination address. the first bit of the destination address, the lsb of the first byte of the frame, is the group/individual bit: this is one for multicast addresses and zero for unicast. the all ones address is the broadcast address, and a special case of multicast. the emac supports recognition of four specific addresses. each specific address requires two registers, specific address register bottom and specific address register top. specific address register bottom stores the first four bytes of the destination address and specific address register top contains the last two bytes. the addresses st ored can be specific, group, local or universal. the destination address of received frames is compared against the data stored in the specific address registers once they have been activated. the addresses are deactivated at reset or when their corresponding specific a ddress register bottom is written. they are activated when specific address register top is written. if a receive frame address ma tches an active address, the frame is copied to memory. the following example illustrates the use of the address match registers for a mac address of 21:43:65:87:a9:cb. preamble 55 sfd d5 da (octet0 - lsb) 21 da(octet 1) 43 da(octet 2) 65 da(octet 3) 87 da(octet 4) a9 da (octet5 - msb) cb sa (lsb) 00 sa 00 sa 00 sa 00 sa 00 sa (msb) 43 sa (lsb) 21
713 6438fCatarmC21-jun-10 at91sam9g45 the sequence above shows the beginning of an et hernet frame. byte order of transmission is from top to bottom as shown. for a successful match to specific address 1, the following address matching registers must be set up: ? base address + 0x98 0x87654321 (bottom) ? base address + 0x9c 0x0000cba9 (top) and for a successful match to the type id register, the following should be set up: ? base address + 0xb8 0x00004321 35.4.7 broadcast address the broadcast address of 0xffffffffffff is recogni zed if the no broadcast bit in the net- work configuration register is zero. 35.4.8 hash addressing the hash address register is 64 bits long and ta kes up two locations in the memory map. the least significant bits are stored in hash register bottom and the most significant bits in hash reg- ister top. the unicast hash enable and the multicast hash enab le bits in the network configuration register enable the reception of hash matched frames. the destination address is reduced to a 6-bit index into the 64-bit hash register using the following hash function. the hash function is an exclusive or of every sixth bit of the destination address. hash_index[5] = da[5] ^ da[11] ^ da[17] ^ da[23] ^ da[29] ^ da[35] ^ da[41] ^ da[47] hash_index[4] = da[4] ^ da[10] ^ da[16] ^ da[22] ^ da[28] ^ da[34] ^ da[40] ^ da[46] hash_index[3] = da[3] ^ da[09] ^ da[15] ^ da[21] ^ da[27] ^ da[33] ^ da[39] ^ da[45] hash_index[2] = da[2] ^ da[08] ^ da[14] ^ da[20] ^ da[26] ^ da[32] ^ da[38] ^ da[44] hash_index[1] = da[1] ^ da[07] ^ da[13] ^ da[19] ^ da[25] ^ da[31] ^ da[37] ^ da[43] hash_index[0] = da[0] ^ da[06] ^ da[12] ^ da[18] ^ da[24] ^ da[30] ^ da[36] ^ da[42] da[0] represents the least significant bit of the first byte received, that is , the multicast/unicast indicator, and da[47] represents the most significant bit of the last byte received. if the hash index points to a bit that is set in the hash register, then the frame is matched accord- ing to whether the frame is multicast or unicast. a multicast match is signalled if the multicast hash enable bit is set. da[0] is 1 and the hash index points to a bit set in the hash register. a unicast match is signalled if the unicast hash enable bit is set. da[0] is 0 and the hash index points to a bit set in the hash register. to receive all multicast frames, the hash register should be set with all ones and the multicast hash enable bit should be set in the network configuration register. 35.4.9 copy all frames (or promiscuous mode) if the copy all frames bit is set in the network configuration register, then all non-errored frames are copied to memory. for example, frames that are too long, too short, or have fcs errors or rx_er asserted during reception are discarded and all others are received. frames with fcs errors are copied to memory if bit 19 in the network configuration register is set.
714 6438fCatarmC21-jun-10 at91sam9g45 35.4.10 type id checking the contents of the type_id register are compared against the length/type id of received frames (i.e., bytes 13 and 14). bit 22 in the receive buffer descriptor status is set if there is a match. the reset state of this register is zero which is unlikely to match the length/type id of any valid ether- net frame. note: a type id match does not affect whether a frame is copied to memory. 35.4.11 vlan support an ethernet encoded 802.1q vlan tag looks like this: the vlan tag is inserted at the 13 th byte of the frame, adding an extra four bytes to the frame. if the vid (vlan identifier) is null (0x000), this indicates a priority-tagged frame. the mac can support frame lengths up to 1536 bytes, 18 byte s more than the original ethernet maximum frame length of 1518 bytes. this is achieved by setting bit 8 in the network configuration register. the following bits in the receive buffer descrip tor status word give information about vlan tagged frames: ? bit 21 set if receive frame is vlan tagged (i.e. type id of 0x8100) ? bit 20 set if receive frame is priority tagged (i.e. type id of 0x8100 and null vid). (if bit 20 is set bit 21 is set also.) ? bit 19, 18 and 17 set to priority if bit 21 is set ? bit 16 set to cfi if bit 21 is set 35.4.12 wake-on-lan support the receive block supports wake-on-lan by det ecting the following events on incoming receive frames: ? magic packet ? arp request to the device ip address ? specific address 1 filter match ? multicast hash filter match if one of these events occurs wake-on-lan detection is indicated by asserting the wol output pin for 64 rx_clk cycles. these events can be individually enabled through bits[19:16] of the wake-on-lan register. also, for wake-on-lan detection to occur, receive enable must be set in the network control register, however a receive buffer does not have to be available. wol asser- tion due to arp request, specific address 1 or multicast filter events occurs even if the frame is errored. for magic packet events, the frame must be correctly formed and error free. a magic packet event is detected if all of the following are true: ? magic packet events are enabled through bit 16 of the wake-on-lan register ? the frames destination address matches specific address 1 ? the frame is correctly formed with no errors ? the frame contains at least 6 bytes of 0xff for synchronization table 35-4. 802.1q vlan tag tpid (tag protocol identifier) 16 bi ts tci (tag control information) 16 bits 0x8100 first 3 bits priority, then cfi bit, last 12 bits vid
715 6438fCatarmC21-jun-10 at91sam9g45 ? there are 16 repetitions of the contents of specific address 1 register immediately following the synchronization an arp request event is detected if all of the following are true: ? arp request events are enabled through bit 17 of the wake-on-lan register ? broadcasts are allowed by bit 5 in the network configuration register ? the frame has a broadcast destination address (bytes 1 to 6) ? the frame has a type id field of 0x0806 (bytes 13 and 14) ? the frame has an arp operation field of 0x0001 (bytes 21 and 22) ? the least significant 16 bits of the frame s arp target protocol address (bytes 41 and 42) match the value programmed in bits[15:0] of the wake-on-lan register the decoding of the arp fields adjusts automatically if a vlan tag is detected within the frame. the reserved value of 0x0000 for the wake-on-lan target address value does not cause an arp request event, even if matched by the frame. a specific address 1 filter match event occurs if all of the following are true: ? specific address 1 events are enabled through bit 18 of the wake-on-lan register ? the frames destination address matches the value programmed in the specific address 1 registers a multicast filter match event occurs if all of the following are true: ? multicast hash events are enabled through bit 19 of the wake-on-lan register ? multicast hash filtering is enabled through bit 6 of the network configuration register ? the frames destination address matches against the multicast hash filter ? the frames destination address is not a broadcast 35.4.13 phy maintenance the register emac_man enables the emac to communicate with a phy by means of the mdio interface. it is used during auto-negotiation to ensure that the emac and the phy are config- ured for the same speed and duplex configuration. the phy maintenance register is implemented as a shift register. writing to the register starts a shift operation which is signalled as complete when bit two is set in the network status register (about 2000 mck cycles later when bit ten is set to zero, and bit eleven is set to one in the net- work configuration register). an interrupt is generated as this bit is set. during this time, the msb of the register is output on the mdio pin and the lsb updated from the mdio pin with each mdc cycle. this causes transmission of a phy management frame on mdio. reading during the shift operation returns the current contents of the shift register. at the end of management operation, the bits have shifted back to their original locations. for a read opera- tion, the data bits are updated with data read from the phy. it is important to write the correct values to the register to ensure a valid phy management frame is produced. the mdio interface can read ieee 802.3 clause 45 phys as well as clause 22 phys. to read clause 45 phys, bits[31:28] should be written as 0x0011. for a description of mdc generation, see the network configuration register in the network control register on page 722 .
716 6438fCatarmC21-jun-10 at91sam9g45 35.4.14 media independent interface the ethernet mac is capable of interfacing to both rmii and mii interfaces. the rmii bit in the emac_usrio register controls the interface that is selected. when this bit is set, the rmii inter- face is selected, else the mii interface is selected. the mii and rmii interface are capable of both 10mb/s and 100mb/s data rates as described in the ieee 802.3u standard. the signals used by the mii and rmii interfaces are described in table 35-5 . the intent of the rmii is to provide a reduced pin count alternative to the ieee 802.3u mii. it uses 2 bits for transmit (etx0 and etx1) and tw o bits for receive (erx0 and erx1). there is a transmit enable (etxen), a receive error (e rxer), a carrier sense (ecrs_dv), and a 50 mhz reference clock (etxck_erefck) for 100mb/s data rate. 35.4.14.1 rmii transmit and receive operation the same signals are used internally for both the rmii and the mii operations. the rmii maps these signals in a more pin-efficient manner. the transmit and receive bits are converted from a 4-bit parallel format to a 2-bit parallel scheme that is clocked at twice the rate. the carrier sense and data valid signals are combined into the ecrsdv signal. this signal contains information on carrier sense, fifo status, and validity of t he data. transmit error bit (etxer) and collision detect (ecol) are not used in rmii mode. table 35-5. pin configuration pin name mii rmii etxck_erefck etxck: transmit clock erefck: reference clock ecrs ecrs: carrier sense ecol ecol: collision detect erxdv erxdv: data valid ecrsdv: carrier sense/data valid erx0 - erx3 erx0 - erx3: 4-bit receiv e data erx0 - erx1: 2-bit receive data erxer erxer: receive erro r erxer: receive error erxck erxck: receive clock etxen etxen: transmit enable etxen: transmit enable etx0-etx3 etx0 - etx3: 4-bi t transmit data etx0 - etx1: 2-bit transmit data etxer etxer: transmit error
717 6438fCatarmC21-jun-10 at91sam9g45 35.5 programming interface 35.5.1 initialization 35.5.1.1 configuration initialization of the emac configuration (e.g., loop-back mode, frequency ratios) must be done while the transmit and receive circ uits are disabled. see the description of the network control register and network configuration register earlier in this document. to change loop-back mode, the following sequence of operations must be followed: 1. write to network control register to disable transmit and receive circuits. 2. write to network control register to change loop-back mode. 3. write to network control register to re-enable transmit or receive circuits. note: these writes to network control register cannot be combined in any way. 35.5.1.2 receive buffer list receive data is written to areas of data (i.e., buffers) in system memory. these buffers are listed in another data structure that also resides in main memory. this data structure (receive buffer queue) is a sequence of descriptor entries as defined in receive buffer descriptor entry on page 706 . it points to this data structure. figure 35-2. receive buffer list to create the list of buffers: 1. allocate a number ( n ) of buffers of 128 bytes in system memory. 2. allocate an area 2 n words for the receive buffer descriptor entry in system memory and create n entries in this list. mark all entries in th is list as owned by emac, i.e., bit 0 of word 0 set to 0. 3. if less than 1024 buffers are defined, the last descriptor must be marked with the wrap bit (bit 1 in word 0 set to 1). 4. write address of receive buffer descriptor entry to emac register receive_buffer queue pointer. 5. the receive circuits can then be enabled by writing to the address recognition registers and then to the network control register. receive buffer queue pointer (mac register) receive buffer 0 receive buffer 1 receive buffer n receive buffer descriptor list (in memory) (in memory)
718 6438fCatarmC21-jun-10 at91sam9g45 35.5.1.3 transmit buffer list transmit data is read from areas of data (the buffers) in system memory these buffers are listed in another data structure that also resides in main memory. this data structure (transmit buffer queue) is a sequence of descriptor entries (as defined in table 35-2 on page 709 ) that points to this data structure. to create this list of buffers: 1. allocate a number ( n ) of buffers of between 1 and 2047 bytes of data to be transmitted in system memory. up to 128 buffers per frame are allowed. 2. allocate an area 2 n words for the transmit buffer descriptor entry in system memory and create n entries in this list. mark all entries in this list as owned by emac, i.e. bit 31 of word 1 set to 0. 3. if fewer than 1024 buffers are defined, the last descriptor must be marked with the wrap bit bit 30 in word 1 set to 1. 4. write address of transmit buffer descriptor entry to emac register transmit_buffer queue pointer. 5. the transmit circuits can then be enabled by writing to the network control register. 35.5.1.4 address matching the emac register-pair hash address and the four specific address register-pairs must be writ- ten with the required values. each register-pair comprises a bottom register and top register, with the bottom register being written first. the addre ss matching is disabled for a particular reg- ister-pair after the bottom-register has been written and re-enabled when the top register is written. see address checking block on page 712. for details of address matching. each reg- ister-pair may be written at any time, regardless of whether the receive circuits are enabled or disabled. 35.5.1.5 interrupts there are 15 interrupt conditions that are detected within the emac. these are ored to make a single interrupt. depending on the overall system design, this may be passed through a further level of interrupt collection (int errupt controller). on receipt of the interrupt signal, the cpu enters the interrupt handler (refer to the aic programmer datasheet). to ascertain which inter- rupt has been generated, read the interrupt status register. note that this register clears itself when read. at reset, all interrupts are disabled. to enable an interrupt, write to interrupt enable register with the pertinent interrupt bit set to 1. to disable an interrupt, write to interrupt disable register with the pertinent interrupt bit set to 1. to check whether an interrupt is enabled or dis- abled, read interrupt mask register: if the bit is set to 1, the interrupt is disabled. 35.5.1.6 transmitting frames to set up a frame for transmission: 1. enable transmit in the network control register. 2. allocate an area of system memory for transmit data. this does not have to be contigu- ous, varying byte lengths can be used as long as they conclude on byte borders. 3. set-up the transmit buffer list. 4. set the network control register to enable transmission and enable interrupts. 5. write data for transmission into these buffers. 6. write the address to transmit buffer descriptor queue pointer. 7. write control and length to word one of the transmit buffer descriptor entry.
719 6438fCatarmC21-jun-10 at91sam9g45 8. write to the transmit start bit in the network control register. 35.5.1.7 receiving frames when a frame is received and the receive circuits are enabled, the emac checks the address and, in the following cases, the frame is written to system memory: ? if it matches one of the four specific address registers. ? if it matches the hash address function. ? if it is a broadcast address (0xf fffffffffff) and broadcasts are allowed. ? if the emac is configured to copy all frames. the register receive buffer queue pointer points to the next entry (see table 35-1 on page 706 ) and the emac uses this as the address in system memory to write the frame to. once the frame has been completely and successfully received an d written to system memory, the emac then updates the receive buffer descriptor entry with the reason for the address match and marks the area as being owned by software. once this is complete an interrupt re ceive complete is set. software is then responsible for handling the data in the buffer and then releasing the buffer by writing the ownership bit back to 0. if the emac is unable to write the data at a rate to match the incoming frame, then an interrupt receive overrun is set. if there is no receive buffer available, i.e., the next buffer is still owned by software, the interrupt receive buffer not avail able is set. if the frame is not successfully received, a statistic register is incremented and the frame is discarded without informing software.
720 6438fCatarmC21-jun-10 at91sam9g45 35.6 ethernet mac 10/100 (e mac) user interface table 35-6. register mapping offset register name access reset 0x00 network control register emac_ncr read-write 0 0x04 network configuration register emac_ncfg read-write 0x800 0x08 network status register emac_nsr read-only - 0x0c reserved 0x10 reserved 0x14 transmit status regist er emac_tsr read-write 0x0000_0000 0x18 receive buffer queue pointer register emac_rbqp read-write 0x0000_0000 0x1c transmit buffer queue pointer register emac_tbqp read-write 0x0000_0000 0x20 receive status register emac_rsr read-write 0x0000_0000 0x24 interrupt status regist er emac_isr read-write 0x0000_0000 0x28 interrupt enable register emac_ier write-only - 0x2c interrupt disable register emac_idr write-only - 0x30 interrupt mask register emac_imr read-only 0x0000_7fff 0x34 phy maintenance register emac_man read-write 0x0000_0000 0x38 pause time register em ac_ptr read-write 0x0000_0000 0x3c pause frames received regi ster emac_pfr read-write 0x0000_0000 0x40 frames transmitted ok regi ster emac_fto read-write 0x0000_0000 0x44 single collision frames register emac_scf read-write 0x0000_0000 0x48 multiple collision frames register emac_mcf read-write 0x0000_0000 0x4c frames received ok register emac_fro read-write 0x0000_0000 0x50 frame check sequence errors r egister emac_fcse read-write 0x0000_0000 0x54 alignment errors regist er emac_ale read-write 0x0000_0000 0x58 deferred transmission frames register emac_dtf read-write 0x0000_0000 0x5c late collisions register emac_lcol read-write 0x0000_0000 0x60 excessive collisions register emac_ecol read-write 0x0000_0000 0x64 transmit underrun errors re gister emac_tund read-write 0x0000_0000 0x68 carrier sense errors register emac_cse read-write 0x0000_0000 0x6c receive resource errors r egister emac_rre read-write 0x0000_0000 0x70 receive overrun errors register emac_rov read-write 0x0000_0000 0x74 receive symbol errors register emac_rse read-write 0x0000_0000 0x78 excessive length errors register emac_ele read-write 0x0000_0000 0x7c receive jabbers register emac_rja read-write 0x0000_0000 0x80 undersize frames register emac_usf read-write 0x0000_0000 0x84 sqe test errors register emac_ste read-write 0x0000_0000 0x88 received length field mismatch register emac_rle read-write 0x0000_0000
721 6438fCatarmC21-jun-10 at91sam9g45 0x90 hash register bottom [31:0] register emac_hrb read-write 0x0000_0000 0x94 hash register top [63:32] register emac_hrt read-write 0x0000_0000 0x98 specific address 1 bottom re gister emac_sa1b read-write 0x0000_0000 0x9c specific address 1 top regi ster emac_sa1t read-write 0x0000_0000 0xa0 specific address 2 bottom re gister emac_sa2b read-write 0x0000_0000 0xa4 specific address 2 top register emac_sa2t read-write 0x0000_0000 0xa8 specific address 3 bottom register emac_sa3b read-write 0x0000_0000 0xac specific address 3 top register emac_sa3t read-write 0x0000_0000 0xb0 specific address 4 bottom register emac_sa4b read-write 0x0000_0000 0xb4 specific address 4 top regi ster emac_sa4t read-write 0x0000_0000 0xb8 type id checking register emac_tid read-write 0x0000_0000 0xc0 user input/output register emac_usrio read-write 0x0000_0000 0xc4 wake on lan register emac_wol read-write 0x0000_0000 0xc8 - 0xfc reserved C C C table 35-6. register mapping (continued) offset register name access reset
722 6438fCatarmC21-jun-10 at91sam9g45 35.6.1 network control register name: emac_ncr address: 0xfffbc000 access: read-write ? lb: loopback asserts the loopback signal to the phy. ? llb: loopback local connects txd to rxd , tx_en to rx_dv , forces full duplex and drives rx_clk and tx_clk with pclk divided by 4. rx_clk and tx_clk may glitch as the emac is switched into and out of internal loop back. it is important that receive and transmit circuits have already been disabled when ma king the switch into and out of internal loop back. ? re: receive enable when set, enables the emac to receive data. when reset, frame reception stops immediately and the receive fifo is cleared. the receive queue pointer register is unaffected. ? te: transmit enable when set, enables the ethernet transmitter to send data. when reset transmission, stops immediately, the transmit fifo and control registers are cleared and the transmit queue pointer register resets to point to the start of the transmit descrip- tor list. ? mpe: management port enable set to one to enable the management port. when zero, forces mdio to high impedance state and mdc low. ? clrstat: clear statistics registers this bit is write only. writing a one clears the statistics registers. ? incstat: increment statistics registers this bit is write only. writing a one increments all the statistics registers by one for test purposes. ? westat: write enable for statistics registers setting this bit to one makes the statistics regi sters writable for functional test purposes. ? bp: back pressure if set in half duplex mode, forces collisions on all received frames. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCthalttstartbp 76543210 westat incstat clrstat mpe te re llb lb
723 6438fCatarmC21-jun-10 at91sam9g45 ? tstart: start transmission writing one to this bit starts transmission. ? thalt: transmit halt writing one to this bit halts transmission as soon as any ongoing frame transmission ends.
724 6438fCatarmC21-jun-10 at91sam9g45 35.6.2 network configuration register name: emac_ncfg address: 0xfffbc004 access: read-write ? spd: speed set to 1 to indicate 100 mbit/s operation, 0 for 10 mbit/s. the value of this pin is reflected on the speed pin. ? fd: full duplex if set to 1, the transmit block ignores the state of collision and carr ier sense and allows receiv e while transmitting. also co n- trols the half_duplex pin. ? caf: copy all frames when set to 1, all valid frames are received. ? jframe: jumbo frames set to one to enable jumbo frames of up to 10240 bytes to be accepted. ? nbc: no broadcast when set to 1, frames addressed to the broadcast address of all ones are not received. ? mti: multicast hash enable when set, multicast frames are received when the 6-bit hash functi on of the destination address points to a bit that is set in the hash register. ? uni: unicast hash enable when set, unicast frames are received when the 6-bit hash function of the destination address points to a bit that is set in the hash register. ? big: receive 1536 bytes frames setting this bit means the emac receives frames up to 1536 bytes in length. normally, the emac would reject any frame above 1518 bytes. ? clk: mdc clock divider set according to system clock speed. this determines by what number system clock is divided to generate mdc. for con- formance with 802.3, mdc must not exceed 2.5mhz (mdc is only active during mdio read and write operations) 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCirxfcsefrhddrfcsrlce 15 14 13 12 11 10 9 8 rbof pae rty clk C big 76543210 uni mti nbc caf jframe C fd spd
725 6438fCatarmC21-jun-10 at91sam9g45 . ? rty: retry test must be set to zero for normal operation. if set to one, the back off between collisions is always one slot time. setting this bit to one helps testing the too many retries condition. also used in the pause frame tests to reduce the pause counters decrement time from 512 bit times, to every rx_clk cycle. ?pae: pause enable when set, transmission pauses when a valid pause frame is received. ? rbof: receive buffer offset indicates the number of bytes by which the received data is offset from the start of the first receive buffer. ? rlce: receive length field checking enable when set, frames with measured lengths shorter than their length fields are di scarded. frames containing a type id in bytes 13 and 14 length/type id = 0600 are not be counted as length errors. ? drfcs: discard receive fcs when set, the fcs field of received frames are not be copied to memory. ? efrhd: enable frames to be received in half-duplex mode wh ile transmitting. ? irxfcs: ignore rx fcs when set, frames with fcs/crc errors are not rejected and no fcs error statistics are counted. for normal operation, this bit must be set to 0. clk mdc 00 mck divided by 8 (mck up to 20 mhz) 01 mck divided by 16 (mck up to 40 mhz) 10 mck divided by 32 (mck up to 80 mhz) 11 mck divided by 64 (mck up to 160 mhz) rbof offset 00 no offset from start of receive buffer 01 one-byte offset from start of receive buffer 10 two-byte offset from start of receive buffer 11 three-byte offset from start of receive buffer
726 6438fCatarmC21-jun-10 at91sam9g45 35.6.3 network status register name: emac_nsr address: 0xfffbc008 access: read-only ?mdio returns status of the mdio_in pin. use the phy main tenance register for reading managed frames rather than this bit. ?idle 0 = the phy logic is running. 1 = the phy management logic is idle (i.e., has completed). 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCidlemdioC
727 6438fCatarmC21-jun-10 at91sam9g45 35.6.4 transmit status register name: emac_tsr address: 0xfffbc014 access: read-write this register, when read, provides details of the status of a tr ansmit. once read, individual bits may be cleared by writing 1 to them. it is not possible to set a bit to 1 by writing to the register. ? ubr: used bit read set when a transmit buffer descriptor is read with its used bit set. cleared by writing a one to this bit. ? col: collision occurred set by the assertion of collision. cle ared by writing a one to this bit. ? rle: retry limit exceeded cleared by writing a one to this bit. ? tgo: transmit go if high transmit is active. ? bex: buffers exhausted mid frame if the buffers run out during transmission of a frame, then transmission stops, fcs shall be bad and tx_er asserted. cleared by writing a one to this bit. ? comp: transmit complete set when a frame has been transmitted. cleared by writing a one to this bit. ? und: transmit underrun set when transmit dma was not able to read data from memory, either because the bus was not granted in time, because a not ok hresp(bus error) was returned or because a used bit was read midway through frame transmission. if this occurs, the transmitter forces bad crc. cleared by writing a one to this bit. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C und comp bex tgo rle col ubr
728 6438fCatarmC21-jun-10 at91sam9g45 35.6.5 receive buffer queue pointer register name: emac_rbqp address: 0xfffbc018 access: read-write this register points to the entry in the receive buffer queue (des criptor list) currently being used. it is written with the st art location of the receive buffer descriptor list. the lower order bits increment as buffers are used up and wrap to their origina l values after either 1024 buffers or when the wrap bit of the entry is set. reading this register returns the location of the descriptor cu rrently being accessed. this value increments as buffers are used. software should not use this register for determining where to remove received frames from the queue as it con- stantly changes as new frames are received. software should instead work its way through the buffer descriptor queue checking the used bits. receive buffer writes also comprise bursts of two words and, as with transmit buffer reads, it is recommended that bit 2 is always written with zero to prevent a burst crossing a 1k bo undary, in violation of section 3.6 of the amba specification. ? addr: receive buffer queue pointer address written with the address of the start of the receive queue, reads as a pointer to the current buffer being used. 31 30 29 28 27 26 25 24 addr 23 22 21 20 19 18 17 16 addr 15 14 13 12 11 10 9 8 addr 76543210 addr C C
729 6438fCatarmC21-jun-10 at91sam9g45 35.6.6 transmit buffer queue pointer register name: emac_tbqp address: 0xfffbc01c access: read-write this register points to the entry in the transmit buffer queue (descriptor list) currently being used. it is written with the s tart location of the transmit buffer descriptor list. the lower order bits increment as buffers are used up and wrap to their origin al values after either 1024 buffers or when the wrap bit of the entry is set. this register can only be written when bit 3 in the transmit status register is low. as transmit buffer reads consist of bursts of two words, it is recommended that bit 2 is always written with zero to prevent a burst crossing a 1k boundary, in violation of section 3.6 of the amba specification. ? addr: transmit buffer queue pointer address written with the address of the start of the transmit queue, reads as a pointer to the first buffer of the frame being transmit - ted or about to be transmitted. 31 30 29 28 27 26 25 24 addr 23 22 21 20 19 18 17 16 addr 15 14 13 12 11 10 9 8 addr 76543210 addr C C
730 6438fCatarmC21-jun-10 at91sam9g45 35.6.7 receive status register name: emac_rsr address: 0xfffbc020 access: read-write this register, when read, provides details of the status of a re ceive. once read, individual bits may be cleared by writing 1 to them. it is not possible to set a bit to 1 by writing to the register. ? bna: buffer not available an attempt was made to get a new buffer and the pointer indicated that it was owned by the processor. the dma rereads the pointer each time a new frame starts un til a valid pointer is found. this bit is set at each attempt that fails even if it has not had a successful pointer read since it has been cleared. cleared by writing a one to this bit. ? rec: frame received one or more frames have been received and placed in memory. cleared by writing a one to this bit. ? ovr: receive overrun the dma block was unable to store the receive frame to me mory, either because the bus was not granted in time or because a not ok hresp(bus error) was returned. the buffer is recovered if this happens. cleared by writing a one to this bit. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCovrrecbna
731 6438fCatarmC21-jun-10 at91sam9g45 35.6.8 interrupt status register name: emac_isr address: 0xfffbc024 access: read-write ? mfd: management frame done the phy maintenance register has completed its operation. cleared on read. ? rcomp: rece ive complete a frame has been stored in memory. cleared on read. ? rxubr: receive used bit read set when a receive buffer descriptor is read with its used bit set. cleared on read. ? txubr: transmit used bit read set when a transmit buffer descriptor is read with its used bit set. cleared on read. ? tund: ethernet transmit buffer underrun the transmit dma did not fetch frame data in time for it to be transmitted or hresp returned not ok. also set if a used bit is read mid-frame or when a new transmit queue pointer is written. cleared on read. ? rle: retry limit exceeded cleared on read. ? txerr: transmit error transmit buffers exhausted in mid-frame - transmit error. cleared on read. ? tcomp: transmit complete set when a frame has been transmitted. cleared on read. ? rovr: receive overrun set when the receive overrun status bit gets set. cleared on read. ? hresp: hresp not ok set when the dma block sees a bus error. cleared on read. ? pfr: pause frame received indicates a valid pause has been received. cleared on a read. ? ptz: pause time zero 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 C wol ptz pfr hresp rovr C C 76543210 tcomp txerr rle tund txubr rxubr rcomp mfd
732 6438fCatarmC21-jun-10 at91sam9g45 ? set when the pause time register, 0x38 decrements to zero. cleared on a read. wol: wake on lan set when a wol event has been triggered (this flag can be set even if the emac is not clocked). cleared on a read.
733 6438fCatarmC21-jun-10 at91sam9g45 35.6.9 interrupt enable register name: emac_ier address: 0xfffbc028 access: write-only ? mfd: management frame sent enable management done interrupt. ? rcomp: rece ive complete enable receive co mplete interrupt. ? rxubr: receive used bit read enable receive used bit read interrupt. ? txubr: transmit used bit read enable transmit used bit read interrupt. ? tund: ethernet transmit buffer underrun enable transmit underrun interrupt. ? rle: retry limit exceeded enable retry limit exceeded interrupt. ? txerr enable transmit buffers exhausted in mid-frame interrupt. ? tcomp: transmit complete enable transmit co mplete interrupt. ? rovr: receive overrun enable receive overrun interrupt. ? hresp: hresp not ok enable hresp not ok interrupt. ? pfr: pause frame received enable pause frame received interrupt. ? ptz: pause time zero 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 C wol ptz pfr hresp rovr C C 76543210 tcomp txerr rle tund txubr rxubr rcomp mfd
734 6438fCatarmC21-jun-10 at91sam9g45 ? enable pause time zero interrupt. wol: wake on lan enable wake on lan interrupt.
735 6438fCatarmC21-jun-10 at91sam9g45 35.6.10 interrupt disable register name: emac_idr address: 0xfffbc02c access: write-only ? mfd: management frame sent disable management done interrupt. ? rcomp: rece ive complete disable receive comp lete interrupt. ? rxubr: receive used bit read disable receive used bit read interrupt. ? txubr: transmit used bit read disable transmit used bit read interrupt. ? tund: ethernet transmit buffer underrun disable transmit underrun interrupt. ? rle: retry limit exceeded disable retry limit exceeded interrupt. ? txerr disable transmit buffers exhausted in mid-frame interrupt. ? tcomp: transmit complete disable transmit complete interrupt. ? rovr: receive overrun disable receive overrun interrupt. ? hresp: hresp not ok disable hresp not ok interrupt. ? pfr: pause frame received disable pause frame received interrupt. ? ptz: pause time zero 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 C wol ptz pfr hresp rovr C C 76543210 tcomp txerr rle tund txubr rxubr rcomp mfd
736 6438fCatarmC21-jun-10 at91sam9g45 ? disable pause time zero interrupt. wol: wake on lan disable wake on lan interrupt.
737 6438fCatarmC21-jun-10 at91sam9g45 35.6.11 interrupt mask register name: emac_imr address: 0xfffbc030 access: read-only ? mfd: management frame sent management done interrupt masked. ? rcomp: rece ive complete receive complete interrupt masked. ? rxubr: receive used bit read receive used bit read interrupt masked. ? txubr: transmit used bit read transmit used bit read interrupt masked. ? tund: ethernet transmit buffer underrun transmit underrun interrupt masked. ? rle: retry limit exceeded retry limit exceeded interrupt masked. ? txerr transmit buffers exhausted in mid-frame interrupt masked. ? tcomp: transmit complete transmit complete interrupt masked. ? rovr: receive overrun receive overrun interrupt masked. ? hresp: hresp not ok hresp not ok interrupt masked. ? pfr: pause frame received pause frame received interrupt masked. ? ptz: pause time zero 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 C wol ptz pfr hresp rovr C C 76543210 tcomp txerr rle tund txubr rxubr rcomp mfd
738 6438fCatarmC21-jun-10 at91sam9g45 ? pause time zero interrupt masked. wol: wake on lan wake on lan interrupt masked.
739 6438fCatarmC21-jun-10 at91sam9g45 35.6.12 phy maintenance register name: emac_man address: 0xfffbc034 access: read-write ?data for a write operation this is written with the data to be written to the phy. after a read operation this contains the data read from the phy. ?code: must be written to 10. reads as written. ? rega: register address specifies the register in the phy to access. ? phya: phy address ? rw: read-write 10 is read; 01 is write. any other va lue is an invalid ph y management frame ? sof: start of frame must be written 01 for a valid frame. 31 30 29 28 27 26 25 24 sof rw phya 23 22 21 20 19 18 17 16 phya rega code 15 14 13 12 11 10 9 8 data 76543210 data
740 6438fCatarmC21-jun-10 at91sam9g45 35.6.13 pause time register name: emac_ptr address: 0xfffbc038 access: read-write ? ptime: pause time stores the current value of the pause time register which is decremented every 512 bit times. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 ptime 76543210 ptime
741 6438fCatarmC21-jun-10 at91sam9g45 35.6.14 hash register bottom name: emac_hrb address: 0xfffbc090 access: read-write ? addr: bits 31:0 of the hash address register. see hash addressing on page 713 . 35.6.15 hash register top name: emac_hrt address: 0xfffbc094 access: read-write ? addr: bits 63:32 of the hash address register. see hash addressing on page 713 . 31 30 29 28 27 26 25 24 addr 23 22 21 20 19 18 17 16 addr 15 14 13 12 11 10 9 8 addr 76543210 addr 31 30 29 28 27 26 25 24 addr 23 22 21 20 19 18 17 16 addr 15 14 13 12 11 10 9 8 addr 76543210 addr
742 6438fCatarmC21-jun-10 at91sam9g45 35.6.16 specific address 1 bottom register name: emac_sa1b address: 0xfffbc098 access: read-write ? addr least significant bits of the destination address. bit zero indicates whether the address is multicast or unicast and corre- sponds to the least significant bit of the first byte received. 35.6.17 specific address 1 top register name: emac_sa1t address: 0xfffbc09c access: read-write ? addr the most significant bits of the destination address, that is bits 47 to 32. 31 30 29 28 27 26 25 24 addr 23 22 21 20 19 18 17 16 addr 15 14 13 12 11 10 9 8 addr 76543210 addr 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 addr 76543210 addr
743 6438fCatarmC21-jun-10 at91sam9g45 35.6.18 specific address 2 bottom register name: emac_sa2b address: 0xfffbc0a0 access: read-write ? addr least significant bits of the destination address. bit zero indicates whether the address is multicast or unicast and corre- sponds to the least significant bit of the first byte received. 35.6.19 specific address 2 top register name: emac_sa2t address: 0xfffbc0a4 access: read-write ? addr the most significant bits of the destination address, that is bits 47 to 32. 31 30 29 28 27 26 25 24 addr 23 22 21 20 19 18 17 16 addr 15 14 13 12 11 10 9 8 addr 76543210 addr 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 addr 76543210 addr
744 6438fCatarmC21-jun-10 at91sam9g45 35.6.20 specific address 3 bottom register name: emac_sa3b address: 0xfffbc0a8 access: read-write ? addr least significant bits of the destination address. bit zero indicates whether the address is multicast or unicast and corre- sponds to the least significant bit of the first byte received. 35.6.21 specific address 3 top register name: emac_sa3t address: 0xfffbc0ac access: read-write ? addr the most significant bits of the destination address, that is bits 47 to 32. 31 30 29 28 27 26 25 24 addr 23 22 21 20 19 18 17 16 addr 15 14 13 12 11 10 9 8 addr 76543210 addr 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 addr 76543210 addr
745 6438fCatarmC21-jun-10 at91sam9g45 35.6.22 specific address 4 bottom register name: emac_sa4b address: 0xfffbc0b0 access: read-write ? addr least significant bits of the destination address. bit zero indicates whether the address is multicast or unicast and corre- sponds to the least significant bit of the first byte received. 35.6.23 specific address 4 top register name: emac_sa4t address: 0xfffbc0b4 access: read-write ? addr the most significant bits of the destination address, that is bits 47 to 32. 31 30 29 28 27 26 25 24 addr 23 22 21 20 19 18 17 16 addr 15 14 13 12 11 10 9 8 addr 76543210 addr 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 addr 76543210 addr
746 6438fCatarmC21-jun-10 at91sam9g45 35.6.24 type id checking register name: emac_tid address: 0xfffbc0b8 access: read-write ? tid: type id checking for use in comparisons with rece ived frames typeid/length field. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 tid 76543210 tid
747 6438fCatarmC21-jun-10 at91sam9g45 35.6.25 user input/output register name: emac_usrio address: 0xfffbc0c0 access: read-write ?rmii when set, this bit enables the rmii operation mode. when reset, it selects the mii mode. ?clken when set, this bit enables the transceiver input clock. setting this bit to 0 reduces power consumption when the treasurer is not used. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCclkenrmii
748 6438fCatarmC21-jun-10 at91sam9g45 35.6.26 wake-on-lan register name: emac_wol access: read-write ? ip: arp request ip address written to define the least significant 16 bits of the target ip address that is matched to generate a wake-on-lan event. a value of zero does not generate an event, even if this is matched by the received frame. ? mag: magic packet event enable when set, magic packet events causes the wol output to be asserted. ? arp: arp request event enable when set, arp request events causes the wol output to be asserted. ? sa1: specific address register 1 event enable when set, specific address 1 events causes the wol output to be asserted. ? mti: multicast hash event enable when set, multicast ha sh events causes the wol output to be asserted. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCmtisa1arpmag 15 14 13 12 11 10 9 8 ip 76543210 ip
749 6438fCatarmC21-jun-10 at91sam9g45 35.6.27 emac statistic registers these registers reset to zero on a read and stick at all ones when they count to their maximum value. they should be read frequently enough to prevent loss of data. the receive statis tics registers are only incremented when the receive enable bit is set in the network control register. to write to these registers, bit 7 must be set in the network control register. the sta tis- tics register block contains the following registers. 35.6.27.1 pause frames received register name: emac_pfr address: 0xfffbc03c access: read-write ? frok: pause frames received ok a 16-bit register counting the number of good pause frames received. a good frame has a length of 64 to 1518 (1536 if bit 8 set in network configuration register) and has no fcs, alignment or receive symbol errors. 35.6.27.2 frames transmitted ok register name: emac_fto address: 0xfffbc040 access: read-write ? ftok: frames transmitted ok a 24-bit register counting the number of frames successfully transmitted, i.e., no underrun and not too many retries. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 frok 76543210 frok 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 ftok 15 14 13 12 11 10 9 8 ftok 76543210 ftok
750 6438fCatarmC21-jun-10 at91sam9g45 35.6.27.3 single collis ion frames register name: emac_scf address: 0xfffbc044 access: read-write ? scf: single collision frames a 16-bit register counting the number of frames experiencing a single collision before being successfully transmitted, i.e., no underrun. 35.6.27.4 multicollision frames register name: emac_mcf address: 0xfffbc048 access: read-write ? mcf: multicollision frames a 16-bit register counting th e number of frames experiencing between two an d fifteen collisions prio r to being successfully transmitted, i.e., no underrun and not too many retries. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 scf 76543210 scf 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 mcf 76543210 mcf
751 6438fCatarmC21-jun-10 at91sam9g45 35.6.27.5 frames received ok register name: emac_fro address: 0xfffbc04c access: read-write ? frok: frames received ok a 24-bit register counting the number of good frames receiv ed, i.e., address recognized and successfully copied to mem- ory. a good frame is of length 64 to 1518 bytes (1536 if bit 8 set in network configuration register) and has no fcs, alignment or receive symbol errors. 35.6.27.6 frames check sequence errors register name: emac_fcse address: 0xfffbc050 access: read-write ? fcse: frame check sequence errors an 8-bit register counting frames that are an integral number of bytes, have bad crc and are between 64 and 1518 bytes in length (1536 if bit 8 set in network configuration register). this register is also incremented if a symbol error is detecte d and the frame is of valid length and has an integral number of bytes. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 frok 15 14 13 12 11 10 9 8 frok 76543210 frok 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 fcse
752 6438fCatarmC21-jun-10 at91sam9g45 35.6.27.7 alignment errors register name: emac_ale address: 0xfffbc054 access: read-write ? ale: alignment errors an 8-bit register counting frames that are not an integral number of bytes long and have bad crc when their length is trun- cated to an integral number of bytes and are between 64 and 1518 bytes in length (1536 if bit 8 set in network configuration register). this register is also incremented if a symbol erro r is detected and the frame is of valid length and does not have an integral number of bytes. 35.6.27.8 deferred transmission frames register name: emac_dtf address: 0xfffbc058 access: read-write ? dtf: deferred transmission frames a 16-bit register counting the number of frames experiencing defer ral due to carrier sense being active on their first attempt at transmission. frames invo lved in any collision are not c ounted nor are fr ames that experienced a transmit underrun. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 ale 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 dtf 76543210 dtf
753 6438fCatarmC21-jun-10 at91sam9g45 35.6.27.9 late collisions register name: emac_lcol address: 0xfffbc05c access: read-write ? lcol: late collisions an 8-bit register counting the number of frames that experience a collis ion after the slot time (512 bits) has expired. a late collision is counted twice; i.e., both as a collision and a late collision. 35.6.27.10 excessive collisions register name: emac_ecol address: 0xfffbc060 access: read-write ? excol: excessive collisions an 8-bit register counting the number of frames that faile d to be transmitted because t hey experienced 16 collisions. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 lcol 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 excol
754 6438fCatarmC21-jun-10 at91sam9g45 35.6.27.11 transmit underrun errors register name: emac_tund address: 0xfffbc064 access: read-write ? tund: transmit underruns an 8-bit register counting the number of frames not transmitte d due to a transmit dma underrun. if this register is incre- mented, then no other statistics register is incremented. 35.6.27.12 carrier sense errors register name: emac_cse address: 0xfffbc068 access: read-write ? cse: carrier sense errors an 8-bit register counting the number of frames transmitted where carrier sense was not seen during transmission or where carrier sense was deasserted after bein g asserted in a transmit frame without collis ion (no underrun). on ly incremented in half-duplex mode. the only effect of a carrier sense error is to increment this register. the behavior of the other statistics registers is unaffected by the detection of a carrier sense error. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 tund 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 cse
755 6438fCatarmC21-jun-10 at91sam9g45 35.6.27.13 receive reso urce errors register name: emac_rre address: 0xfffbc06c access: read-write ? rre: receive resource errors a 16-bit register counting the number of frames that were address matched but could not be copied to memory because no receive buffer was available. 35.6.27.14 receive overrun errors register name: emac_rov address: 0xfffbc070 access: read-write ? rovr: receive overrun an 8-bit register counting the number of frames that are address recognized but were not copied to memory due to a receive dma overrun. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 rre 76543210 rre 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 rovr
756 6438fCatarmC21-jun-10 at91sam9g45 35.6.27.15 receive symbol errors register name: emac_rse address: 0xfffbc074 access: read-write ? rse: receive symbol errors an 8-bit register counting the number of frames that had rx_er asserted during reception. receive symbol errors are also counted as an fcs or alignment error if the frame is between 64 and 1518 bytes in length (1536 if bit 8 is set in the network configuration register). if the frame is larger, it is recorded as a jabber error. 35.6.27.16 excessive length errors register name: emac_ele address: 0xfffbc078 access: read-write ? exl: excessive length errors an 8-bit register counting the number of frames received e xceeding 1518 bytes (1536 if bit 8 set in network configuration register) in length but do not have either a crc error, an alignm ent error nor a rece ive symbol error. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 rse 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 exl
757 6438fCatarmC21-jun-10 at91sam9g45 35.6.27.17 receive jabbers register name: emac_rja address: 0xfffbc07c access: read-write ? rjb: receive jabbers an 8-bit register counting the number of frames received e xceeding 1518 bytes (1536 if bit 8 set in network configuration register) in length and have ei ther a crc error, an alignment er ror or a receiv e symbol error. 35.6.27.18 undersize frames register name: emac_usf address: 0xfffbc080 access: read-write ? usf: undersize frames an 8-bit register counting the number of frames received less than 64 bytes in length but do not have either a crc error, an alignment error or a receive symbol error. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 rjb 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 usf
758 6438fCatarmC21-jun-10 at91sam9g45 35.6.27.19 sqe test errors register name: emac_ste address: 0xfffbc084 access: read-write ? sqer: sqe test errors an 8-bit register counting the number of frames where col was not asserted within 96 bit times (an interframe gap) of tx_en being deasserted in half duplex mode. 35.6.27.20 received length field mismatch register name: emac_rle address: 0xfffbc088 access: read-write ? rlfm: receive length field mismatch an 8-bit register counting the number of frames received that have a measured length shorter than that extracted from its length field. checking is enabled through bit 16 of the netw ork configuration register. frames containing a type id in bytes 13 and 14 (i.e., length/type id 0x0600) are not counted as length field errors, neither are excessive length frames. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 sqer 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 rlfm
759 6438fCatarmC21-jun-10 at91sam9g45 36. high speed multimedia card interface (hsmci) 36.1 description the high speed multimedia card interface (hsmci) supports the multimedia card (mmc) specification v4.3, the sd memo ry card specification v2.0, th e sdio v1.1 specification and ce-ata v1.1. the hsmci includes a command register, response registers, data registers, timeout counters and error detection logic that automatically handle the transmission of commands and, when required, the reception of the associated responses and data with a limited processor overhead. the hsmci supports stream, block and multi block data read and write, and is compatible with the dma controller, minimizing processor intervention for large buffers transfers. the hsmci operates at a rate of up to master clock divided by 2 and supports the interfacing of 1 slot(s). each slot may be used to interfac e with a high speed multimediacard bus (up to 30 cards) or with an sd memory card. only one slot can be selected at a time (slots are multi- plexed). a bit field in the sd card register performs this selection. the sd memory card communication is based on a 9-pin interface (clock, command, four data and three power lines) and the high speed multimedia card on a 7-pin interface (clock, com- mand, one data, three power lines and one reserved for future use). the sd memory card interface also supports high speed multimedia card operations. the main differences between sd and high speed multimedia cards are the initialization process and the bus topology. hsmci fully supports ce-ata revision 1.1, bui lt on the mmc system specification v4.0. the module includes dedicated hardware to issue the command completion signal and capture the host command completion signal disable. 36.2 embedded characteristics ? compatibility with multimedia ca rd specification version 4.3 ? compatibility with sd memory ca rd specification version 2.0 ? compatibility with sdio specification version v2.0. ? compatibility with memory stick pro ? compatibility with ce ata
760 6438fCatarmC21-jun-10 at91sam9g45 36.3 block diagram figure 36-1. block diagram note: 1. when several hsmci (x hsmci) are embedded in a pr oduct, mcck refers to hsmcix_ck, mccda to hsmcix_cda, mcday to hsmcix_day. mcda3 (1) mcda2 (1) mcda1 (1) mcda0 (1) mccda (1) mcck (1) hsmci interface interrupt control hsmci interrupt pio apb bridge pmc mck apb mcda7 (1) mcda6 (1) mcda5 (1) mcda4 (1) dmac
761 6438fCatarmC21-jun-10 at91sam9g45 36.4 application block diagram figure 36-2. application block diagram 36.5 pin name list notes: 1. i: input, o: output, pp: push/pull, od: open drain. 2. when several hsmci (x hsmci) are embedded in a produc t, mcck refers to hsmcix_ck, mccda to hsmcix_cda, mcday to hsmcix_day. 23456 17 mmc 23456 17 8 sdcard 9 physical layer hsmci interface application layer ex: file system, audio, security, etc. 9 1011 1213 8 table 36-1. i/o lines description pin name (2) pin description type (1) comments mccda command/response i/o/pp/od cm d of an mmc or sdcard/sdio mcck clock i/o clk of an mmc or sd card/sdio mcda0 - mcda7 data 0..7 of slot a i/o/pp dat[0..7] of an mmc dat[0..3] of an sd card /sdio
762 6438fCatarmC21-jun-10 at91sam9g45 36.6 product dependencies 36.6.1 i/o lines the pins used for interfacing the high speed mu ltimedia cards or sd ca rds are multiplexed with pio lines. the programmer must first program the pio controllers to assign the peripheral func- tions to hsmci pins. 36.6.2 power management the hsmci is clocked through the power management controller (pmc), so the programmer must first configure the pmc to enable the hsmci clock. 36.6.3 interrupt the hsmci interface has an interrupt line connected to the advanced interrupt controller (aic). handling the hsmci interrupt requires programming the aic before configuring the hsmci. table 36-2. i/o lines instance signal i/o line peripheral hsmci0 mci0_cda pa1 a hsmci0 mci0_ck pa0 a hsmci0 mci0_da0 pa2 a hsmci0 mci0_da1 pa3 a hsmci0 mci0_da2 pa4 a hsmci0 mci0_da3 pa5 a hsmci0 mci0_da4 pa6 a hsmci0 mci0_da5 pa7 a hsmci0 mci0_da6 pa8 a hsmci0 mci0_da7 pa9 a hsmci1 mci1_cda pa22 a hsmci1 mci1_ck pa31 a hsmci1 mci1_da0 pa23 a hsmci1 mci1_da1 pa24 a hsmci1 mci1_da2 pa25 a hsmci1 mci1_da3 pa26 a hsmci1 mci1_da4 pa27 a hsmci1 mci1_da5 pa28 a hsmci1 mci1_da6 pa29 a hsmci1 mci1_da7 pa30 a table 36-3. peripheral ids instance id hsmci0 11 hsmci1 29
763 6438fCatarmC21-jun-10 at91sam9g45 36.7 bus topology figure 36-3. high speed multimedia me mory card bus topology the high speed multimedia card communication is based on a 13-pin serial bus interface. it has three communication lines and four supply lines. notes: 1. i: input, o: output, pp : push/pull, od: open drain. 2. when several hsmci (x hsmci) are embedded in a product, mcck refers to hsmcix_ck, mccda to hsmcix_cda, mcday to hsmcix_day. 23456 17 mmc 91011 12138 table 36-4. bus topology pin number name type (1) description hsmci pin name ( (2) (slot z) 1 dat[3] i/o/pp data mcdz3 2 cmd i/o/pp/od command/response mccdz 3 vss1 s supply voltage ground vss 4 vdd s supply voltage vdd 5 clk i/o clock mcck 6 vss2 s supply voltage ground vss 7 dat[0] i/o/pp data 0 mcdz0 8 dat[1] i/o/pp data 1 mcdz1 9 dat[2] i/o/pp data 2 mcdz2 10 dat[4] i/o/pp data 4 mcdz4 11 dat[5] i/o/pp data 5 mcdz5 12 dat[6] i/o/pp data 6 mcdz6 13 dat[7] i/o/pp data 7 mcdz7
764 6438fCatarmC21-jun-10 at91sam9g45 figure 36-4. mmc bus connections (one slot) note: when several hsmci (x hsmci) are embedded in a product, mcck refers to hsmcix_ck, mccda to hsmcix_cda mcday to hsmcix_day. figure 36-5. sd memory card bus topology the sd memory card bus includes the signals listed in table 36-5 . notes: 1. i: input, o: output, pp: push pull, od: open drain. 2. when several hsmci (x hsmci) are embedded in a product, mcck refers to hsmcix_ck, mccda to hsmcix_cda, mcday to hsmcix_day. mccda mcda0 mcck hsmci 23456 17 mmc1 9 1011 1213 8 23456 17 mmc2 9 1011 1213 8 23456 17 mmc3 9 1011 1213 8 23456 17 8 sd card 9 table 36-5. sd memory card bus signals pin number name type (1) description hsmci pin name (2) (slot z) 1 cd/dat[3] i/o/pp card detect/ data line bit 3 mcdz3 2 cmd pp command/response mccdz 3 vss1 s supply voltage ground vss 4 vdd s supply voltage vdd 5 clk i/o clock mcck 6 vss2 s supply voltage ground vss 7 dat[0] i/o/pp data line bit 0 mcdz0 8 dat[1] i/o/pp data line bit 1 or interrupt mcdz1 9 dat[2] i/o/pp data line bit 2 mcdz2
765 6438fCatarmC21-jun-10 at91sam9g45 figure 36-6. sd card bus connections with one slot note: when several hsmci (x hsmci) are embedded in a product, mcck refers to hsmcix_ck, mccda to hsmcix_cda mcday to hsmcix_day. when the hsmci is configured to operate with sd memory cards, the width of the data bus can be selected in the hsmci_sdcr register. cleari ng the sdcbus bit in this register means that the width is one bit; setting it means that the width is four bits. in the case of high speed multi- media cards, only the data line 0 is used. the other data lines can be used as independent pios. 36.8 high speed multim edia card operations after a power-on reset, the cards are initialized by a special message-based high speed multi- media card bus protocol. each message is represented by one of the following tokens: ? command: a command is a token that starts an operation. a command is sent from the host either to a single card (addressed command) or to all connected cards (broadcast command). a command is transferred serially on the cmd line. ? response: a response is a token which is sent from an addressed card or (synchronously) from all connected cards to the host as an answer to a previously received command. a response is transferred serially on the cmd line. ? data: data can be transferred from the card to the host or vice versa. data is transferred via the data line. card addressing is implemented using a sess ion address assigned during the initialization phase by the bus controller to all currently connected cards. their unique cid number identifies individual cards. the structure of commands, responses and data blocks is described in the high speed multime- dia-card system specification. see also table 36-6 on page 766 . high speed multimediacard bus data transfers are composed of these tokens. there are different types of operations. addressed operations always contain a command and a response token. in addition, some operations have a data token; the others transfer their infor- mation directly within the command or response structure. in this case, no data token is present in an operation. the bits on the dat and the cmd lines are transferred synchronous to the clock hsmci clock. two types of data transfer commands are defined: ? sequential commands: these commands initiate a continuous data stream. they are terminated only when a stop command follows on the cmd line. this mode reduces the command overhead to an absolute minimum. 23456 17 mcda0 - mcda3 mccda mcck 8 sd card 9
766 6438fCatarmC21-jun-10 at91sam9g45 ? block-oriented commands: th ese commands send a data block succeeded by crc bits. both read and write operations allow either single or multiple block transmission. a multiple block transmission is terminated when a stop co mmand follows on the cm d line similarly to the sequential read or when a multiple block transmission has a pre-defined block count ( see data transfer operation on page 768. ). the hsmci provides a set of registers to perform the entire range of high speed multimedia card operations. 36.8.1 command - response operation after reset, the hsmci is disabled and becomes valid after setting the mcien bit in the hsmci_cr control register. the pwsen bit saves power by dividing the hsmci clock by 2 pwsdiv + 1 when the bus is inactive. the two bits, rdproof and wrproof in the hsmci mode register (hsmci_mr) allow stopping the hsmci clock during read or write access if the internal fifo is full. this will guar- antee data integrity, not bandwidth. all the timings for high speed multimedia card are defined in the high speed multimediacard system specification. the two bus modes (open drain and push/pull) needed to process all the operations are defined in the hsmci command register. the hsmci_cm dr allows a command to be carried out. for example, to perform an all_send_cid command: the command all_send_cid and the fields and values for the hsmci_cmdr control regis- ter are described in table 36-6 and table 36-7 . note: bcr means broadcast command with response. host command n id cycles cid cmd s t content crc e z ****** z s t content z z z table 36-6. all_send_cid command description cmd index type argumen t resp abbreviation command description cmd2 bcr [31:0] stuff bits r2 all_send_cid asks all cards to send their cid numbers on the cmd line table 36-7. fields and values for hsmci_cmdr command register field value cmdnb (command number) 2 (cmd2) rsptyp (response type) 2 (r2: 136 bits response) spcmd (special command) 0 (not a special command) opcmd (open drain command) 1 maxlat (max latency for command to response) 0 (nid cycles ==> 5 cycles)
767 6438fCatarmC21-jun-10 at91sam9g45 the hsmci_argr contains the argument field of the command. to send a command, the user must perform the following steps: ? fill the argument register (hsmci _argr) with the command argument. ? set the command register (hsmci_cmdr) (see table 36-7 ). the command is sent immediately after writing the command register. as soon as the command register is written, then the status bit cmdrdy in the status register (hsmci_sr) is cleared. it is released and the end of the card response. if the command requires a response, it can be read in the hsmci response register (hsmci_rspr). the response size can be from 48 bits up to 136 bits depending on the com- mand. the hsmci embeds an error detection to prevent any corrupted data during the transfer. the following flowchart shows how to send a command to the card and read the response if needed. in this example, the status register bits are polled but setting the appropriate bits in the interrupt enable register (hsmci_ier) allows using an interrupt method. trcmd (transfer command) 0 (no transfer) trdir (transfer direction) x (available only in transfer command) trtyp (transfer type) x (available only in transfer command) iospcmd (sdio special command) 0 (not a special command) table 36-7. fields and values for hsmci_cmdr command register field value
768 6438fCatarmC21-jun-10 at91sam9g45 figure 36-7. command/response functional flow diagram note: 1. if the command is send_op_cond, the crc error flag is always present (refer to r3 res ponse in the high speed multime- dia card specification). 36.8.2 data transfer operation the high speed multimedia card allows several r ead/write operations (single block, multiple blocks, stream, etc.). these kinds of transfer can be selected setting the transfer type (trtyp) field in the hsmci command register (hsmci_cmdr). these operations can be done using the features of the dma controller. in all cases, the block length (blklen field) must be defined either in the mode register hsmci_mr, or in the block register hsmci_blkr. this field determines the size of the data block. consequent to mmc specification 3.1, two types of multiple block read (or write) transactions are defined (the host can use either one at any time): ? open-ended/infinite multiple block read (or write): return ok return error (1) set the command argument hsmci_argr = argument (1) set the command hsmci_cmdr = command read hsmci_sr cmdrdy status error flags? read response if required ye s wait for command ready status flag check error bits in the status register (1) 0 1
769 6438fCatarmC21-jun-10 at91sam9g45 the number of blocks for the read (or write) multiple block operation is not defined. the card will continuously transfer (o r program) data blocks until a stop transmission command is received. ? multiple block read (or write) with pre-defined block count (since version 3.1 and higher): the card will transfer (or prog ram) the requested number of data blocks and terminate the transaction. the stop command is not required at the end of this type of multiple block read (or write), unless terminated with an error. in order to start a multiple block read (or write) with pre-defined block count, the host must correctly program the hsmci block register (hsmci_blkr). otherwise the ca rd will start an open-ended mu ltiple block read. the bcnt field of the block register defines the number of blocks to transfer (from 1 to 65535 blocks). programming the value 0 in the bcnt field co rresponds to an infinite block transfer. 36.8.3 read operation the following flowchart ( figure 36-8 ) shows how to read a single block with or without use of dmac facilities. in this example, a polling met hod is used to wait for the end of read. similarly, the user can configure the interrupt enable regist er (hsmci_ier) to trigger an interrupt at the end of read.
770 6438fCatarmC21-jun-10 at91sam9g45 figure 36-8. read functional flow diagram note: 1. it is assumed th at this command has been correctly sent (see figure 36-7 ). 2. this field is also accessible in the hsmci block register (hsmci_blkr). read status register hsmci_sr send select/deselect_card command (1) to select the card send set_blocklen command (1) read with dmac number of words to read = 0 ? poll the bit rxrdy = 0? read data = hsmci_rdr number of words to read = number of words to read -1 send read_single_block command (1) ye s set the dmaen bit hsmci_dma |= dmaen set the block length (in bytes) hsmci_blkr |= (blocklength << 16) (2) configure the dma channel x dmac_saddrx = data address dmac_btsize = blocklength/4 dmachen[x] = true send read_single_block command (1) read status register hsmci_sr poll the bit xfrdone = 0? ye s return return ye s no no no ye s no number of words to read = blocklength/4 reset the dmaen bit mci_dma &= ~dmaen set the block length (in bytes) hsmci_mr l= (blocklength<<16) (2) set the block count (if neccessary) hsmci_blkr l= (blockcount<<0)
771 6438fCatarmC21-jun-10 at91sam9g45 36.8.4 write operation in write operation, the hsmci mode register (hsmci_mr) is used to define the padding value when writing non-multiple block size. if the bit padv is 0, then 0x00 value is used when padding data, otherwise 0xff is used. if set, the bit dmaen in the hsmci_dma register enables dma transfer. the following flowchart ( figure 36-9 ) shows how to write a single block with or without use of dma facilities. polling or interrupt method can be used to wait for the end of write according to the contents of the interrupt mask register (hsmci_imr).
772 6438fCatarmC21-jun-10 at91sam9g45 figure 36-9. write functional flow diagram note: 1. it is assumed th at this command has been correctly sent (see figure 36-7 ). 2. this field is also accessible in the hsmci block register (hsmci_blkr). send select/deselect_card command (1) to select the card send set_blocklen command (1) write using dmac send write_single_block command (1) configure the dma channel x dmac_daddrx = data address to write dmac_btsize = blocklength/4 send write_single_block command (1) read status register mci_sr poll the bit xfrdone = 0? ye s no ye s no read status register hsmci_sr number of words to write = 0 ? poll the bit txrdy = 0? hsmci_tdr = data to write number of words to write = number of words to write -1 ye s return no ye s no number of words to write = blocklength/4 dmac_chen[x] = true reset thedmaen bit hsmci_dma &= ~dmaen set the block length (in bytes) hsmci_mr |= (blocklength) <<16) (2) set the block count (if necessary) hsmci_blkr |= (blockcount << 0) set the dmaen bit hsmci_dma |= dmaen set the block length (in bytes) hsmci_blkr |= (blocklength << 16) (2) return
773 6438fCatarmC21-jun-10 at91sam9g45 the following flowchart ( figure 36-10 ) shows how to manage read multiple block and write mul- tiple block transfers with the dma controller. polling or in terrupt method can be used to wait for the end of write according to the contents of the interrupt mask register (hsmci_imr). figure 36-10. read multiple block and write multiple block notes: 1. it is assumed that this co mmand has been correctly sent (see figure 36-7 ). 2. handle errors reported in hsmci_sr. send select/deselect_card command (1) to select the card send set_blocklen command (1) set the block length hsmci_mr |= (blocklength << 16) set the dmaen bit hsmci_dma |= dmaen configure the hdma channel x dmac_saddrx and dmac_daddrx dmac_btsize = blocklength/4 send write_multiple_block or read_multiple_block command (1) read status register dmac_ebcisr and poll bit cbtc[x] new buffer ? (2) no dmac_chen[x] = true poll the bit xfrdone = 1 no return ye s send stop_transmission command (1) ye s read status register hsmci_sr and poll bit fifoempty
774 6438fCatarmC21-jun-10 at91sam9g45 36.8.5 write_single_block operation using dma controller 1. wait until the current command execution has successfully terminated. a. check that cmdrdy and notbusy fields are asserted in hsmci_sr 2. program the block length in the card. this value defines the value block_length. 3. program the block length in the hsmci configuration register with block_length value. 4. program hsmci_dma register with the following fields: C offset field with dma_offset. C chksize is user defined and set according to dmac_dcsize. C dmaen is set to true to enable dma hardware handshaking in the hsmci. this bit was previously set to false. 5. issue a write_single_block comman d writing hsmci_arg then hsmci_cmdr. 6. program the dma controller. a. read the channel register to choose an available (disabled) channel. b. clear any pending interrupts on the channel from the previous dmac transfer by reading the dmac_ebcisr register. c. program the channel registers. d. the dmac_saddrx register for channel x must be set to the location of the source data. when the first data location is not word aligned, the two lsb bits define the temporary value called dma_offset. the two lsb bits of dmac_saddrx must be set to 0. e. the dmac_daddrx register for channel x must be set with the starting address of the hsmci_fifo address. f. program dmac_ctrlax register of channel x with the following fields values: Cdst_width is set to word. Csrc_width is set to word. Cdcsize must be set according to the value of hsmci_dma, chksize field. Cbtsize is programmed with ceiling((block_length + dma_offset) / 4), where the ceiling function is the function that re turns the smallest integer not less than x. g. program dmac_ctrlbx register for channel x with the following fields values: Cdst_incr is set to incr, the block_length value must not be larger than the hsmci_fifo aperture. Csrc_incr is set to incr. Cfc field is programmed with memory to peripheral flow control mode. Cboth dst_dscr and src_dscr are set to 1 (descriptor fetch is disabled). Cdif and sif are set with their respective layer id. if sif is different from dif, the dma controller is able to prefetch data and write hsmci simultaneously. h. program dmac_cfgx register for channel x with the following fields values: Cfifocfg defines the watermark of the dmac channel fifo. Cdst_h2sel is set to true to enable hardware handshaking on the destination. Cdst_per is programmed with the hardware handshaking id of the targeted hsmci host controller.
775 6438fCatarmC21-jun-10 at91sam9g45 i. enable channel x, writing one to dmac_cher[x]. the dmac is ready and waiting for request. 7. wait for xfrdone in hsmci_sr register. 36.8.6 read_single_block operation using dma controller 36.8.6.1 block length is multiple of 4 1. wait until the current command execution has successfully completed. a. check that cmdrdy and notbusy are asserted in hsmci_sr. 2. program the block length in the card. this value defines the value block_length. 3. program the block length in the hsmci configuration register with block_length value. 4. set rdproof bit in hsmci_mr to avoid overflow. 5. program hsmci_dma register with the following fields: C ropt field is set to 0. C offset field is set to 0. C chksize is user defined. C dmaen is set to true to enable dmac hardware handshaking in the hsmci. this bit was previously set to false. 6. issue a read_single_block command. 7. program the dma controller. a. read the channel register to choose an available (disabled) channel. b. clear any pending interrupts on the channel from the previous dma transfer by reading the dmac_ebcisr register. c. program the channel registers. d. the dmac_saddrx register for channel x must be set with the starting address of the hsmci_fifo address. e. the dmac_daddrx register for channel x must be word aligned. f. program dmac_ctrlax register of channel x with the following fields values: Cdst_width is set to word. Csrc_width is set to word. Cscsize must be set according to the value of hsmci_dma, chksize field. Cbtsize is programmed with block_length/4. g. program dmac_ctrlbx register for channel x with the following fields values: C dst_incr is set to incr. C src_incr is set to incr. C fc field is programmed with periphera l to memory flow control mode. C both dst_dscr and src_dscr are set to 1 (descriptor fetch is disabled). C dif and sif are set with their respective layer id. if sif is different from dif, the dma controller is able to prefetch data and write hsmci simultaneously. h. program dmac_cfgx register for channel x with the following fields values: Cfifocfg defines the watermark of the dma channel fifo. Csrc_h2sel is set to true to enable hardware handshaking on the destination. Csrc_per is programmed with the hardware handshaking id of the targeted hsmci host controller.
776 6438fCatarmC21-jun-10 at91sam9g45 Cenable channel x, writing one to dmac_cher[x]. the dmac is ready and waiting for request. 8. wait for xfrdone in hsmci_sr register. 36.8.6.2 block length is not multiple of 4 and padding not used (ropt field in hsmci_dma register set to 0) in the previous dma transfer flow (block length multiple of 4), the dma controller is configured to use only word ahb access. when the block length is no longer a multiple of 4 this is no longer true. the dma controller is programmed to copy exactly the block length number of bytes using 2 transfer descriptors. 1. use the previous step until read_single_block then 2. program the dma controller to use a two descriptors linked list. a. read the channel register to choose an available (disabled) channel. b. clear any pending interrupts on the channel from the previous dma transfer by reading the dmac_ebcisr register. c. program the channel registers in the memory for the first descriptor. this descriptor will be word oriented. this descriptor is refe rred to as lli_w, st anding for lli word oriented transfer. d. the lli_w.dmac_saddrx field in memory must be set with the starting address of the hsmci_fifo address. e. the lli_w.dmac_daddrx field in th e memory must be word aligned. f. program lli_w.dmac_ctrlax with the following fields values: Cdst_width is set to word. Csrc_width is set to word. Cscsize must be set according to the value of hsmci_dma, chksize field. Cbtsize is programmed with block_length/4. if btsize is zero, this descriptor is skipped later. g. program lli_w.dmac_ctrlbx with the following fields values: Cdst_incr is set to incr Csrc_incr is set to incr Cfc field is programmed with peripheral to memory flow control mode. Csrc_dscr is set to zero. (descriptor fetch is enabled for the src) Cdst_dscr is set to one. (descriptor fetch is disabled for the dst) Cdif and sif are set with their respective layer id. if sif is different from dif, dma controller is able to prefetch data and write hsmci simultaneously. h. program lli_w.dmac_cfgx register for channel x with the following fields values: Cfifocfg defines the watermark of the dma channel fifo. Cdst_rep is set to zero meaning that address are contiguous. Csrc_h2sel is set to true to enable hardware handshaking on the destination. Csrc_per is programmed with the hardware handshaking id of the targeted hsmci host controller. i. program lli_w.dmac_dscrx with the address of lli_b descriptor. and set dscrx_if to the ahb layer id. this operation actually links the word oriented
777 6438fCatarmC21-jun-10 at91sam9g45 descriptor on the second byte oriented descriptor. when block_length[1:0] is equal to 0 (multiple of 4) lli_w.dmac_dscrx points to 0, only lli_w is relevant. j. program the channel registers in the memory for the second descriptor. this descriptor will be byte oriented . this descriptor is referred to as lli_b, standing for lli byte oriented. k. the lli_b.dmac_saddrx field in memory must be set with the starting address of the hsmci_fifo address. l. the lli_b.dmac_daddrx is not relevant if previous word aligned descriptor was enabled. if 1, 2 or 3 bytes are transferred that address is user defined and not word aligned. m. program lli_b.dmac_ctrlax with the following fields values: Cdst_width is set to byte. Csrc_width is set to byte. Cscsize must be set according to the value of hsmci_dma, chksize field. Cbtsize is programmed with block_length[1:0]. (last 1, 2, or 3 bytes of the buffer). n. program lli_b.dmac_ctrlbx with the following fields values: Cdst_incr is set to incr Csrc_incr is set to incr Cfc field is programmed with peripheral to memory flow control mode. Cboth src_dscr and dst_dscr are set to 1 (descriptor fetch is disabled) or next descriptor location points to 0. Cdif and sif are set with their respective layer id. if sif is different from dif, dma controller is able to prefetch da ta and write hsmci simultaneously. o. program lli_b.dmac_cfgx memory location for channel x with the following fields values: C fifocfg defines the watermark of the dma channel fifo. C src_h2sel is set to true to enable hardware handshaking on the destination. C src_per is programmed with the hardware handshaking id of the targeted hsmci host controller. p. program lli_b.dmac_dscr with 0. q. program dmac_ctrlbx register for channel x with 0. its content is updated with the lli fetch operation. r. program dmac_dscrx with the address of lli_w if block_length greater than 4 else with address of lli_b. s. enable channel x writing one to dmac_c her[x]. the dmac is ready and waiting for request. 3. wait for xfrdone in hsmci_sr register. 36.8.6.3 block length is not multiple of 4, with padding value (ropt field in hsmci_dma register set to 1) when the ropt field is set to one, the dma controller performs only word access on the bus to transfer a non-multiple of 4 block length. unlik e previous flow, in which the transfer size is rounded to the nearest multiple of 4. 1. program the hsmci interface, see previous flow. C ropt field is set to 1. 2. program the dma controller
778 6438fCatarmC21-jun-10 at91sam9g45 a. read the channel register to choose an available (disabled) channel. b. clear any pending interrupts on the channel from the previous dma transfer by reading the dmac_ebcisr register. c. program the channel registers. d. the dmac_saddrx register for channel x must be set with the starting address of the hsmci_fifo address. e. the dmac_daddrx register for channel x must be word aligned. f. program dmac_ctrlax register of channel x with the following fields values: Cdst_width is set to word Csrc_width is set to word Cscsize must be set according to the value of hsmci_dma.chksize field. Cbtsize is programmed with ceiling(block_length/4). g. program dmac_ctrlbx register for channel x with the following fields values: Cdst_incr is set to incr Csrc_incr is set to incr Cfc field is programmed with peripheral to memory flow control mode. Cboth dst_dscr and src_dscr are set to 1. (descriptor fetch is disabled) Cdif and sif are set with their respective layer id. if sif is different from dif, the dma controller is able to prefetch data and write hsmci simultaneously. h. program dmac_cfgx register for channel x with the following fields values: Cfifocfg defines the watermark of the dma channel fifo. Csrc_h2sel is set to true to enable hardware handshaking on the destination. Csrc_per is programmed with the hardware handshaking id of the targeted hsmci host controller. Cenable channel x writing one to dmac_cher[x]. the dmac is ready and waiting for request. 3. wait for xfrdone in hsmci_sr register. 36.8.7 write_multiple_block 36.8.7.1 one block per descriptor 1. wait until the current command execution has successfully terminated. a. check that cmdrdy and notbusy are asserted in hsmci_sr. 2. program the block length in the card. this value defines the value block_length. 3. program the block length in the hsmci configuration register with block_length value. 4. program hsmci_dma register with the following fields: C offset field with dma_offset. C chksize is user defined. C dmaen is set to true to enable dmac hardware handshaking in the hsmci. this bit was previously set to false. 5. issue a write_multiple_block command. 6. program the dma controller to use a list of descriptors. each descriptor transfers one block of data. block n of data is transferred with descriptor lli(n).
779 6438fCatarmC21-jun-10 at91sam9g45 a. read the channel register to choose an available (disabled) channel. b. clear any pending interrupts on the channel from the previous dmac transfer by reading the dmac_ebcisr register. c. program a list of descriptors. d. the lli(n).dmac_saddrx memory location for channel x must be set to the loca- tion of the source data. when the first data location is not word aligned, the two lsb bits define the temporary value called dma_offset. the two lsb bits of lli(n).dmac_saddrx must be set to 0. e. the lli(n).dmac_daddrx register for ch annel x must be set with the starting address of the hsmci_fifo address. f. program lli(n).dmac_ctrlax register of channel x with the following fields values: Cdst_width is set to word. Csrc_width is set to word. Cdcsize must be set according to the value of hsmci_dma, chksize field. Cbtsize is programmed with ceiling((block_length + dma_offset)/4). g. program lli(n).dmac_ctrlbx register for channel x with the following fields values: Cdst_incr is set to incr. Csrc_incr is set to incr. Cdst_dscr is set to 0 (fetch operation is enabled for the destination). Csrc_dscr is set to 1 (sou rce address is contiguous). Cfc field is programmed with memory to peripheral flow control mode. Cboth dst_dscr and src_dscr are set to 1 (descriptor fetch is disabled). Cdif and sif are set with their respective layer id. if sif is different from dif, dma controller is able to prefetch da ta and write hsmci simultaneously. h. program lli(n).dmac_cfgx register for channel x with the following fields values: Cfifocfg defines the watermark of the dma channel fifo. Cdst_h2sel is set to true to enable hardware handshaking on the destination. Csrc_rep is set to 0. (contiguous memory access at block boundary) Cdst_per is programmed with the hardware handshaking id of the targeted hsmci host controller. i. if lli(n) is the last descriptor, then lli(n).dscr points to 0 else lli(n) points to the start address of lli(n+1). j. program dmac_ctrlbx for channel register x with 0. its content is updated with the lli fetch operation. k. program dmac_dscrx for channel register x with the address of the first descrip- tor lli(0). l. enable channel x writing one to dmac _cher[x]. the dma is ready and waiting for request. 7. poll cbtc[x] bit in the dmac_ebcisr register. 8. if a new list of buffers shall be transferred, repeat step 6. check and handle hsmci errors. 9. poll fifoempty field in the hsmci_sr.
780 6438fCatarmC21-jun-10 at91sam9g45 10. send the stop_transmission co mmand writing hsmci_arg then hsmci_cmdr. 11. wait for xfrdone in hsmci_sr register. 36.8.8 read_multiple_block 36.8.8.1 block length is a multiple of 4 1. wait until the current command execution has successfully terminated. a. check that cmdrdy and notbusy are asserted in hsmci_sr. 2. program the block length in the card. this value defines the value block_length. 3. program the block length in the hsmci configuration register with block_length value. 4. set rdproof bit in hsmci_mr to avoid overflow. 5. program hsmci_dma register with the following fields: C ropt field is set to 0. C offset field is set to 0. C chksize is user defined. C dmaen is set to true to enable dmac hardware handshaking in the hsmci. this bit was previously set to false. 6. issue a read_multiple_block command. 7. program the dma controller to use a list of descriptors: a. read the channel register to choose an available (disabled) channel. b. clear any pending interrupts on the channel from the previous dma transfer by reading the dmac_ebcisr register. c. program the channel registers in the memory with the first descriptor. this descrip- tor will be word oriented. this descriptor is referred to as lli_w(n ), standing for lli word oriented transfer for block n . d. the lli_w(n).dmac_saddrx field in memory must be set with the starting address of the hsmci_fifo address. e. the lli_w(n).dmac_daddrx field in the memory must be word aligned. f. program lli_w(n).dmac_ctrlax with the following fields values: Cdst_width is set to word Csrc_width is set to word Cscsize must be set according to the value of hsmci_dma, chksize field. Cbtsize is programmed with block_length/4. g. program lli_w(n).dmac_ctrlbx with the following fields values: Cdst_incr is set to incr. Csrc_incr is set to incr. Cfc field is programmed with peripheral to memory flow control mode. Csrc_dscr is set to 0 (descripto r fetch is enabled for the src). Cdst_dscr is set to true (descriptor fetch is disabled for the dst). Cdif and sif are set with their respective layer id. if sif is different from dif, the dma controller is able to prefetch data and write hsmci simultaneously.
781 6438fCatarmC21-jun-10 at91sam9g45 h. program lli_w(n).dmac_cfgx register for channel x with the following fields values: Cfifocfg defines the watermark of the dma channel fifo. Cdst_rep is set to zero. addresses are contiguous. Csrc_h2sel is set to true to enable hardware handshaking on the destination. Csrc_per is programmed with the hardware handshaking id of the targeted hsmci host controller. i. program lli_w(n).dmac_dscrx with the address of lli_w(n+1) descriptor. and set the dscrx_if to the ahb layer id. this operation actually links descriptors together. if lli_w(n) is the last descriptor then lli_w(n).dmac_dscrx points to 0. j. program dmac_ctrlbx register for channel x with 0. its content is updated with the lli fetch operation. k. program dmac_dscrx register for channel x with the address of lli_w(0). l. enable channel x writing one to dmac _cher[x]. the dma is ready and waiting for request. 8. poll cbtc[x] bit in the dmac_ebcisr register. 9. if a new list of buffer shall be transferred repeat step 6. check and handle hsmci errors. 10. poll fifoempty field in the hsmci_sr. 11. send the stop_transmission command writing the hsmci_arg then the hsmci_cmdr. 12. wait for xfrdone in hsmci_sr register. 36.8.8.2 block length is not multiple of 4. (ropt field in hsmci_dma register set to 0) two dma transfer descriptors are used to perform the hsmci block transfer. 1. use the previous step to configure the hsmci to perform a read_multiple_block command. 2. issue a read_multiple_block command. 3. program the dma controller to use a list of descriptors. a. read the channel register to choose an available (disabled) channel. b. clear any pending interrupts on the channel from the previous dmac transfer by reading the dmac_ebcisr register. c. for every block of data repeat the following procedure: d. program the channel registers in the memory for the first descriptor. this descriptor will be word oriented. this descriptor is referred to as lli_w(n ) standing for lli word oriented transfer for block n . e. the lli_w(n).dmac_saddrx field in memory must be set with the starting address of the hsmci_fifo address. f. the lli_w(n).dmac_daddrx field in the memory must be word aligned. g. program lli_w(n).dmac_ctrlax with the following fields values: Cdst_width is set to word. Csrc_width is set to word. Cscsize must be set according to the value of hsmci_dma, chksize field. Cbtsize is programmed with block_length/4. if btsize is zero, this descriptor is skipped later.
782 6438fCatarmC21-jun-10 at91sam9g45 h. program lli_w(n).dmac_ctrlbx with the following fields values: Cdst_incr is set to incr. Csrc_incr is set to incr. Cfc field is programmed with peripheral to memory flow control mode. Csrc_dscr is set to 0 (descripto r fetch is enabled for the src). Cdst_dscr is set to true (descriptor fetch is disabled for the dst). Cdif and sif are set with their respective layer id. if sif is different from dif, the dma controller is able to prefetch data and write hsmci simultaneously. i. program lli_w(n).dmac_cfgx register for channel x with the following fields values: Cfifocfg defines the watermark of the dma channel fifo. Cdst_rep is set to zero. address are contiguous. Csrc_h2sel is set to true to enable hardware handshaking on the destination. Csrc_per is programmed with the hardware handshaking id of the targeted hsmci host controller. j. program lli_w(n).dmac_dscrx with the address of lli_b(n) descriptor. and set the dscrx_if to the ahb layer id. this operation actually links the word oriented descriptor on the second byte oriented descriptor. when block_length[1:0] is equal to 0 (multiple of 4) lli_w(n).dmac_dscrx points to 0, only lli_w(n) is relevant. k. program the channel registers in the memory for the second descriptor. this descriptor will be byte oriented . this descriptor is referred to as lli_b(n), standing for lli byte oriented. l. the lli_b(n).dmac_saddrx field in memory must be set with the starting address of the hsmci_fifo address. m. the lli_b(n).dmac_daddrx is not relevant if previous word aligned descriptor was enabled. if 1, 2 or 3 bytes are transferred, that address is user defined and not word aligned. n. program lli_b(n).dmac_ctrlax with the following fields values: Cdst_width is set to byte. Csrc_width is set to byte. Cscsize must be set according to the value of hsmci_dma, chksize field. Cbtsize is programmed with block_length[1:0]. (last 1, 2, or 3 bytes of the buffer). o. program lli_b(n).dmac_ctrlbx with the following fields values: C dst_incr is set to incr. C src_incr is set to incr. C fc field is programmed with periphera l to memory flow control mode. C both src_dscr and dst_dscr are set to 1 (descriptor fetch is disabled) or next descriptor location points to 0. C dif and sif are set with their respective layer id. if sif is different from dif, the dma controller is able to prefetch data and write hsmci simultaneously. p. program lli_b(n).dmac_cfgx memory lo cation for channel x with the following fields values: C fifocfg defines the watermark of the dmac channel fifo. C src_h2sel is set to true to enable hardware handshaking on the destination.
783 6438fCatarmC21-jun-10 at91sam9g45 C src_per is programmed with the hardware handshaking id of the targeted hsmci host controller q. program lli_b(n).dmac_dscr with address of descriptor lli_w(n+1). if lli_b(n) is the last descriptor, then program lli_b(n).dmac_dscr with 0. r. program dmac_ctrlbx register for channel x with 0, its content is updated with the lli fetch operation. s. program dmac_dscrx with the address of lli_w(0) if block_length is greater than 4 else with address of lli_b(0). t. enable channel x writing one to dmac_c her[x]. the dmac is ready and waiting for request. 4. enable dmadone interrupt in the hsmci_ier register. 5. poll cbtc[x] bit in the dmac_ebcisr register. 6. if a new list of buffers shall be transferred, repeat step 7. check and handle hsmci errors. 7. poll fifoempty field in the hsmci_sr. 8. send the stop_transmission co mmand writing hsmci_arg then hsmci_cmdr. 9. wait for xfrdone in hsmci_sr register. 36.8.8.3 block length is not a multiple of 4. (ropt field in hsmci_dma register set to 1) one dma transfer descriptor is used to perform the hsmci block transfer, the dma writes a rounded up value to the nearest multiple of 4. 1. use the previous step to configure the hsmci to perform a read_multiple_block. 2. set the ropt field to 1 in the hsmci_dma register. 3. issue a read_multiple_block command. 4. program the dma controller to use a list of descriptors: a. read the channel register to choose an available (disabled) channel. b. clear any pending interrupts on the channel from the previous dmac transfer by reading the dmac_ebcisr register. c. program the channel registers in the memory with the first descriptor. this descrip- tor will be word oriented. this descriptor is referred to as lli_w(n ), standing for lli word oriented transfer for block n . d. the lli_w(n).dmac_saddrx field in memory must be set with the starting address of the hsmci_fifo address. e. the lli_w(n).dmac_daddrx field in the memory must be word aligned. f. program lli_w(n).dmac_ctrlax with the following fields values: Cdst_width is set to word. Csrc_width is set to word. Cscsize must be set according to the value of hsmci_dma, chksize field. Cbtsize is programmed with ceiling(block_length/4). g. program lli_w(n).dmac_ctrlbx with the following fields values: Cdst_incr is set to incr Csrc_incr is set to incr Cfc field is programmed with peripheral to memory flow control mode. Csrc_dscr is set to 0. (descrip tor fetch is enabled for the src)
784 6438fCatarmC21-jun-10 at91sam9g45 Cdst_dscr is set to true. (descriptor fetch is disabled for the dst) Cdif and sif are set with their respective layer id. if sif is different from dif, the dma controller is able to prefetch data and write hsmci simultaneously. h. program lli_w(n).dmac_cfgx register for channel x with the following fields values: Cfifocfg defines the watermark of the dma channel fifo. Cdst_rep is set to zero. address are contiguous. Csrc_h2sel is set to true to enable hardware handshaking on the destination. Csrc_per is programmed with the hardware handshaking id of the targeted hsmci host controller. i. program lli_w(n).dmac_dscrx with the address of lli_w(n+1) descriptor. and set the dscrx_if to the ahb layer id. this operation actually links descriptors together. if lli_w(n) is the last descriptor then lli_w(n).dmac_dscrx points to 0. j. program dmac_ctrlbx register for channel x with 0. its content is updated with the lli fetch operation. k. program dmac_dscrx register for channel x with the address of lli_w(0). l. enable channel x writing one to dmac_c her[x]. the dmac is ready and waiting for request. 5. poll cbtc[x] bit in the dmac_ebcisr register. 6. if a new list of buffers shall be transferred repeat step 7. check and handle hsmci errors. 7. poll fifoempty field in the hsmci_sr. 8. send the stop_transmission command writing the hsmci_arg then the hsmci_cmdr. 9. wait for xfrdone in hsmci_sr register. 36.9 sd/sdio card operation the high speed multimedia card interface allows processing of sd memory (secure digital memory card) and sdio (sd input output) card commands. sd/sdio cards are based on the multi media card (mmc) format, but are physically slightly thicker and feature higher data transfer rates, a lock switch on the side to prevent accidental overwriting and security featur es. the physical form factor, pin assignment and data transfer protocol are forward-compatible with the high speed multimedia card with some additions. sd slots can actually be used for more than flash memory cards. devices that support sdio can use small devices designed for the sd form fact or, such as gps receivers, wi-fi or bluetooth adapters, modems, barcode readers, irda adapters, fm radio tuners, rfid readers, digital cam- eras and more. sd/sdio is covered by numerous patents and trademarks, and licensing is only available through the secure digital card association. the sd/sdio card communication is based on a 9-pin interface (clock, command, 4 x data and 3 x power lines). the communication protocol is defined as a part of this specification. the main difference between the sd/sdio card and t he high speed multimedia card is the initial- ization process.
785 6438fCatarmC21-jun-10 at91sam9g45 the sd/sdio card register (hsmci_sdcr) allows selection of the card slot and the data bus width. the sd/sdio card bus allows dynamic configur ation of the number of data lines. after power up, by default, the sd/sdio card uses only dat0 for data transfer. after initialization, the host can change the bus width (number of active data lines). 36.9.1 sdio data transfer type sdio cards may transfer data in either a multi-byte (1 to 512 bytes) or an optional block format (1 to 511 blocks), while the sd memory cards are fixed in the block transfer mode. the trtyp field in the hsmci command register (hsmci_c mdr) allows to choose between sdio byte or sdio block transfer. the number of bytes/blocks to transfer is set through the bcnt field in the hsmci block regis- ter (hsmci_blkr). in sdio block mode, the field blklen must be set to the data block size while this field is not used in sdio byte mode. an sdio card can have multiple i/o or combined i/o and memo ry (called combo card). within a multi-function sdio or a combo card, there are multiple devices (i/o and memory) that share access to the sd bus. in order to allow the sharing of access to the host among multiple devices, sdio and combo cards can implement the optional concept of suspend/resume (refer to the sdio specification for more details). to send a suspend or a resume command, the host must set the sdio special command field (iospcmd) in the hsmci command register. 36.9.2 sdio interrupts each function within an sdio or combo card may implement interrupts (refer to the sdio specification for more details). in order to allow the sdio card to interrupt the host, an interrupt function is added to a pin on the dat[1] line to signal the cards interrupt to the host. an sdio interrupt on each slot can be enabled through the hsmci interrupt enable register. the sdio interrupt is sampled regardless of the currently selected slot. 36.10 ce-ata operation ce-ata maps the streamlined ata command set onto the mmc interface. the ata task file is mapped onto mmc register space. ce-ata utilizes five mmc commands: ? go_idle_state (cmd0): used for hard reset. ? stop_transmission (cmd12): causes the ata command currently executing to be aborted. ? fast_io (cmd39): used for single register access to the ata taskfile registers, 8 bit access only. ? rw_multiple_registers (cmd60): used to issue an ata command or to access the control/status registers. ? rw_multiple_block (cmd61): used to transfer data for an ata command. ce-ata utilizes the same mmc command s equences for initialization as traditional mmc devices. 36.10.1 executing an ata polling command 1. issue read_dma_ext with rw_multiple_ register (cmd60) for 8kb of data. 2. read the ata status register until drq is set.
786 6438fCatarmC21-jun-10 at91sam9g45 3. issue rw_multiple_block (cmd61) to transfer data. 4. read the ata status register until drq && bsy are set to 0. 36.10.2 executing an ata interrupt command 1. issue read_dma_ext with rw_multiple_ register (cmd60) for 8kb of data with nien field set to zero to enable the command completion signal in the device. 2. issue rw_multiple_block (cmd61) to transfer data. 3. wait for completion signal received interrupt. 36.10.3 aborting an ata command if the host needs to abort an ata command prior to the completion signal it must send a special command to avoid potential collision on t he command line. the spcmd field of the hsmci_cmdr must be set to 3 to issue the ce-ata completion signal disable command. 36.10.4 ce-ata error recovery several methods of ata command failure may occur, including: ? no response to an mmc command, such as rw_multiple_register (cmd60). ? crc is invalid for an mmc command or response. ? crc16 is invalid for an mmc data packet. ? ata status register reflects an error by setting the err bit to one. ? the command completion signal does not arrive within a host specified time out period. error conditions are expected to happen infreq uently. thus, a robust error recovery mechanism may be used for each error event. the recommended error recovery procedure after a timeout is: ? issue the command completion signal disable if nien was cleared to zero and the rw_multiple_block (cmd61) response has been received. ? issue stop_transmission (cmd12) and successfully receive the r1 response. ? issue a software reset to the ce-ata device using fast_io (cmd39). if stop_tranmission (cmd12) is successful , then the device is again ready for ata com- mands. however, if the error recovery procedure does not work as expected or there is another timeout, the next step is to issue go_idle_state (cmd0) to the device. go_idle_state (cmd0) is a hard reset to the device and completely resets all device states. note that after issuing go_idle_state (cmd0), a ll device initialization needs to be completed again. if the ce-ata device completes all mmc commands corr ectly but fails the ata command with the err bit set in the ata status register , no error recovery action is required. the ata command itself failed implying that the device could not complete the action requested, how- ever, there was no communication or protocol failu re. after the device signals an error by setting the err bit to one in the ata status register, the host may attempt to retry the command. 36.11 hsmci boot operation mode in boot operation mode, the processor can read boot data from the slave (mmc device) by keep- ing the cmd line low after power-on before issuing cmd1. the data can be read from either the boot area or user area, depending on register setting.
787 6438fCatarmC21-jun-10 at91sam9g45 36.11.1 boot procedure, processor mode 1. configure the hsmci data bus width programming sdcbus field in the hsmci_sdcr register. the boot_bus_width field located in the device extended csd register must be set accordingly. 2. set the byte count to 512 bytes and the block count to the desired number of blocks, writing blklen and bcnt fields of the hsmci_blkr register. 3. issue the boot operation request command by writing to the hsmci_cmdr register with spcmd field set to bootreq, trdir set to read and trcmd set to start data transfer. 4. the boot_ack field located in the hsmci_cmdr register must be set to one, if the boot_ack field of the mmc device located in the extended csd register is set to one. 5. host processor can copy boot data sequentially as soon as the rxrdy flag is asserted. 6. when data transfer is completed, host processor shall terminate the boot stream by writing the hsmci_cmdr register with spcmd field set to bootend. 36.11.2 boot procedure, dma mode 1. configure the hsmci data bus width by programming sdcbus field in the hsmci_sdcr register. the boot_bus_width field in the device extended csd register must be set accordingly. 2. set the byte count to 512 bytes and the block count to the desired number of blocks by writing blklen and bcnt fields of the hsmci_blkr register. 3. enable dma transfer in the hsmci_dma register. 4. configure dma controller, program the total amount of data to be transferred and enable the relevant channel. 5. issue the boot operation request command by writing to the hsmci_cmdr register with spcnd set to bootreq, trdir set to read and trcmd set to start data transfer. 6. dma controller copies the boot partition to the memory. 7. when dma transfer is completed, host processor shall terminate the boot stream by writing the hsmci_cmdr register with spcmd field set to bootend.
788 6438fCatarmC21-jun-10 at91sam9g45 36.12 hsmci transfer done timings 36.12.1 definition the xfrdone flag in the hsmci_sr indicate s exactly when the read or write sequence is finished. 36.12.2 read access during a read access, the xfrdone flag behaves as shown in figure 36-11 . figure 36-11. xfrdone during a read access cmd line mci re a d cmd c a rd re s pon s e cmdrdy fl a g d a t a 1 s t block l as t block not bus y fl a g xfrdone fl a g the cmdrdy fl a g i s rele as ed 8 t b it a fter the end of the c a rd re s pon s e.
789 6438fCatarmC21-jun-10 at91sam9g45 36.12.3 write access during a write access, the xfrdone flag behaves as shown in figure 36-12 . figure 36-12. xfrdone during a write access cmd line mci writecmd c a rd re s pon s e cmdrdy fl a g d a t a bus - d0 1 s t block not bus y fl a g xfrdone fl a g the cmdrdy fl a g i s rele as ed 8 t b it a fter the end of the c a rd re s pon s e. l as t block d0 1 s t block l as t block d0 i s tied b y the c a rd d0 i s rele as ed
790 6438fCatarmC21-jun-10 at91sam9g45 36.13 multimedia card inte rface (mci) user interface note: 1. the response register can be read by n accesses at the same hsmci_rspr or at consecut ive addresses (0x20 to 0x2c). n depends on the size of the response. table 36-8. register mapping offset register name access reset 0x00 control register hsmci_cr write C 0x04 mode register hsmci_mr read-write 0x0 0x08 data timeout register hsmci_dtor read-write 0x0 0x0c sd/sdio card register hsmci_sdcr read-write 0x0 0x10 argument register hsmci_argr read-write 0x0 0x14 command register hsmci_cmdr write C 0x18 block register hsmci_blkr read-write 0x0 0x1c completion signal timeout register hsmci_cstor read-write 0x0 0x20 response register (1) hsmci_rspr read 0x0 0x24 response register (1) hsmci_rspr read 0x0 0x28 response register (1) hsmci_rspr read 0x0 0x2c response register (1) hsmci_rspr read 0x0 0x30 receive data register hsmci_rdr read 0x0 0x34 transmit data register hsmci_tdr write C 0x38 - 0x3c reserved C C C 0x40 status register hsmci_sr read 0xc0e5 0x44 interrupt enable register hsmci_ier write C 0x48 interrupt disable register hsmci_idr write C 0x4c interrupt mask register hsmci_imr read 0x0 0x50 dma configuration register hsmci_dma read-write 0x00 0x54 configuration register hsmci_cfg read-write 0x00 0x58-0xe0 reserved C C C 0xe4 write protection mode register hsmci_wpmr read-write C 0xe8 write protection status register hsmci_wpsr read-only C 0xec - 0xfc reserved C C C 0x100-0x124 reserved C C C 0x200-0x3ffc fifo memory aperture hsmci_fifo read-write 0x0
791 6438fCatarmC21-jun-10 at91sam9g45 36.13.1 hsmci control register name: hsmci_cr addresses: 0xfff80000 (0), 0xfffd0000 (1) access: write-only ? mcien: multi-media interface enable 0 = no effect. 1 = enables the multi-media interface if mcdis is 0. ? mcidis: multi-media interface disable 0 = no effect. 1 = disables the multi-media interface. ? pwsen: power save mode enable 0 = no effect. 1 = enables the power saving mode if pwsdis is 0. warning: before enabling this mode, the user must set a value different from 0 in the pwsdiv field (mode register, hsmci_mr). ? pwsdis: power save mode disable 0 = no effect. 1 = disables the power saving mode. ? swrst: software reset 0 = no effect. 1 = resets the hsmci. a software triggered hardwa re reset of the hsmci interface is performed. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 swrst C C C pwsdis pwsen hsmcidis mcien
792 6438fCatarmC21-jun-10 at91sam9g45 36.13.2 hsmci mode register name: hsmci_mr addresses: 0xfff80004 (0), 0xfffd0004 (1) access: read-write ? clkdiv: clock divider high speed multimedia card in terface clock (mcck or hsmci_ck) is master clock (mck) divided by (2*(clkdiv+1)). ? pwsdiv: power saving divider high speed multimedia card interface clock is divided by 2 (pwsdiv) + 1 when entering power saving mode. warning: this value must be different from 0 before enabling the power save mode in the hsmci_cr (hsmci_pwsen bit). ? rdproof read proof enable enabling read proof allows to stop the hs mci clock during read access if the internal fifo is full. this will guarantee data integrity, no t bandwidth. 0 = disables read proof. 1 = enables read proof. ? wrproof write proof enable enabling write proof allows to st op the hsmci clock during write access if the internal fifo is full. this will guarantee data integrity, no t bandwidth. 0 = disables write proof. 1 = enables write proof. ? fbyte: force byte transfer enabling force byte transfer allow byte transfers, so that transfer of blocks with a size different from modulo 4 can be supported. warning: blklen value depends on fbyte. 0 = disables force byte transfer. 1 = enables force byte transfer. ? padv: padding value 0 = 0x00 value is used when padding data in write transfer. 1 = 0xff value is used when padding data in write transfer. padv may be only in manual transfer. 31 30 29 28 27 26 25 24 blklen 23 22 21 20 19 18 17 16 blklen 15 14 13 12 11 10 9 8 C padv fbyte wrproof rdproof pwsdiv 76543210 clkdiv
793 6438fCatarmC21-jun-10 at91sam9g45 ? blklen: data block length this field determines the size of the data block. this field is also accessible in th e hsmci block register (hsmci_blkr). bits 16 and 17 must be set to 0 if fbyte is disabled. note: in sdio byte mode, blklen field is not used.
794 6438fCatarmC21-jun-10 at91sam9g45 36.13.3 hsmci data timeout register name: hsmci_dtor addresses: 0xfff80008 (0), 0xfffd0008 (1) access: read-write ? dtocyc: data timeout cycle number ? dtomul: data timeout multiplier these fields determine the maximum numb er of master clock cycles that the hs mci waits between two data block trans- fers. it equals (dtocyc x multiplier). multiplier is defined by dtomul as shown in the following table: if the data time-out set by dtocyc and dtomul has been exceeded, the data time-out error flag (dtoe) in the hsmci status register (hsmci_sr) raises. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C dtomul dtocyc dtomul multiplier 0001 00116 010128 011256 1001024 1014096 1 1 0 65536 1 1 1 1048576
795 6438fCatarmC21-jun-10 at91sam9g45 36.13.4 hsmci sdcard/sdio register name: hsmci_sdcr addresses: 0xfff8000c (0), 0xfffd000c (1) access: read-write ? sdcsel: sdcard/sdio slot ? sdcbus: sdcard/sdio bus width 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 sdcbus CCCC sdcsel sdcsel sdcard/sdio slot 00 slot a is selected . 01C 10C 11C sdcbus bus width 00 1 bit 104 bit 118 bit
796 6438fCatarmC21-jun-10 at91sam9g45 36.13.5 hsmci argument register name: hsmci_argr addresses: 0xfff80010 (0), 0xfffd0010 (1) access: read-write ? arg: command argument 31 30 29 28 27 26 25 24 arg 23 22 21 20 19 18 17 16 arg 15 14 13 12 11 10 9 8 arg 76543210 arg
797 6438fCatarmC21-jun-10 at91sam9g45 36.13.6 hsmci command register name: hsmci_cmdr addresses: 0xfff80014 (0), 0xfffd0014 (1) access: write-only this register is write-protected while cm drdy is 0 in hsmci_sr. if an interrupt command is sent, this register is only writeable by an interrupt response (field spcmd). this means that the current command execution cannot be interrupted or modified. ? cmdnb: command number ? rsptyp: response type ? spcmd: special command 31 30 29 28 27 26 25 24 CCCCboot_ackatacs iospcmd 23 22 21 20 19 18 17 16 C C trtyp trdir trcmd 15 14 13 12 11 10 9 8 C C C maxlat opdcmd spcmd 76543210 rsptyp cmdnb rsp response type 0 0 no response. 0 1 48-bit response. 1 0 136-bit response. 1 1 r1b response type spcmd command 0 0 0 not a special cmd. 001 initialization cmd: 74 clock cycles for in itialization sequence. 010 synchronized cmd: wait for the end of the current data block transfer before sending the pending command. 011 ce-ata completion signal disable command. the host cancels the ability for the device to return a command completion signal on the command line. 100 interrupt command: corresponds to the interrupt mode (cmd40).
798 6438fCatarmC21-jun-10 at91sam9g45 ? opdcmd: open drain command 0 = push pull command 1 = open drain command ? maxlat: max latency for command to response 0 = 5-cycle max latency 1 = 64-cycle max latency ? trcmd: transfer command ? trdir: transfer direction 0 = write 1 = read ? trtyp: transfer type 101 interrupt response: corresponds to the interrupt mode (cmd40). 110 boot operation request. start a boot operation mode, the host processor can read boot data from the mmc device directly. 111 end boot operation. this command allows the host proces sor to terminate the boot operation mode. trcmd transfer type 0 0 no data transfer 0 1 start data transfer 1 0 stop data transfer 11reserved trtyp transfer type 0 0 0 mmc/sdcard single block 0 0 1 mmc/sdcard multiple block 010mmc stream 0 1 1 reserved 1 0 0 sdio byte 101sdio block 1 1 0 reserved 1 1 1 reserved spcmd command
799 6438fCatarmC21-jun-10 at91sam9g45 ? iospcmd: sdio special command ? atacs: ata with command completion signal 0 = normal operation mode. 1 = this bit indicates that a completion signal is expe cted within a programmed amount of time (hsmci_cstor). ? boot_ack: boot operation acknowledge. the master can choose to receive the boot acknowledge fr om the slave when a boot request command is issued. when set to one this field indicates that a boot acknowledge is expected within a programmabl e amount of time defined with dtomul and dtocyc fields located in the hsmci_dtor r egister. if the acknowledge pattern is not received then an acknowledge timeout error is raised. if the acknowledge patt ern is corrupted then an acknowledge pattern error is set. iospcmd sdio special command type 0 0 not a sdio special command 0 1 sdio suspend command 1 0 sdio resume command 11reserved
800 6438fCatarmC21-jun-10 at91sam9g45 36.13.7 hsmci block register name: hsmci_blkr addresses: 0xfff80018 (0), 0xfffd0018 (1) access: read-write ? bcnt: mmc/sdio block count - sdio byte count this field determines the number of data byte(s) or block(s) to transfer. the transfer data type and the authorized values for bcnt field are determined by the tr typ field in the hsmci com- mand register (hsmci_cmdr): warning: in sdio byte and block modes, writing to the 7 last bi ts of bcnt field, is forbidden and may lead to unpredict- able results. ? blklen: data block length this field determines the size of the data block. this field is also accessible in the hsmci mode register (hsmci_mr). bits 16 and 17 must be set to 0 if fbyte is disabled. note: in sdio byte mode, blklen field is not used. 31 30 29 28 27 26 25 24 blklen 23 22 21 20 19 18 17 16 blklen 15 14 13 12 11 10 9 8 bcnt 76543210 bcnt trtyp type of transfer bcnt authorized values 0 0 1 mmc/sdcard multiple block from 1 to 65635: value 0 corresponds to an infinite block transfer. 1 0 0 sdio byte from 1 to 512 bytes: value 0 corresponds to a 512-byte transfer. values from 0x200 to 0xffff are forbidden. 1 0 1 sdio block from 1 to 511 blocks: value 0 corresponds to an infinite block transfer. values from 0x200 to 0xffff are forbidden. other values - reserved.
801 6438fCatarmC21-jun-10 at91sam9g45 36.13.8 hsmci completion signal timeout register name: hsmci_cstor addresses: 0xfff8001c (0), 0xfffd001c (1) access: read-write ? cstocyc: completion signal timeout cycle number ? cstomul: completion signal timeout multiplier these fields determine the maximum numb er of master clock cycles that the hs mci waits between two data block trans- fers. its value is calculated by (cstocyc x multiplier). these fields determine the maximum number of master clock cycles that the hsmci waits between the end of the data transfer and the assertion of the completion signal. the data transfer comprises data phase and the optional busy phase. if a non-data ata command is issued, the hsmci starts waiting immediately after the end of the response until the comple- tion signal. multiplier is defined by cstomul as shown in the following table: if the data time-out set by cstocyc and cstomul has b een exceeded, the completion signal time-out error flag (cstoe) in the hsmci status register (hsmci_sr) raises. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C cstomul cstocyc cstomul multiplier 0001 00116 010128 011256 1 0 0 1024 1 0 1 4096 1 1 0 65536 1 1 1 1048576
802 6438fCatarmC21-jun-10 at91sam9g45 36.13.9 hsmci response register name: hsmci_rspr addresses: 0xfff80020 (0), 0xfffd0020 (1) access: read-only ? rsp: response note: 1. the response register can be read by n accesses at the same hsmci_rspr or at consecut ive addresses (0x20 to 0x2c). n depends on the size of the response. 36.13.10 hsmci receive data register name: hsmci_rdr addresses: 0xfff80030 (0), 0xfffd0030 (1) access: read-only ? data: data to read 31 30 29 28 27 26 25 24 rsp 23 22 21 20 19 18 17 16 rsp 15 14 13 12 11 10 9 8 rsp 76543210 rsp 31 30 29 28 27 26 25 24 data 23 22 21 20 19 18 17 16 data 15 14 13 12 11 10 9 8 data 76543210 data
803 6438fCatarmC21-jun-10 at91sam9g45 36.13.11 hsmci transmit data register name: hsmci_tdr addresses: 0xfff80034 (0), 0xfffd0034 (1) access: write-only ? data: data to write 31 30 29 28 27 26 25 24 data 23 22 21 20 19 18 17 16 data 15 14 13 12 11 10 9 8 data 76543210 data
804 6438fCatarmC21-jun-10 at91sam9g45 36.13.12 hsmci status register name: hsmci_sr addresses: 0xfff80040 (0), 0xfffd0040 (1) access: read-only ? cmdrdy: command ready 0 = a command is in progress. 1 = the last command has been sent. cleared when writing in the hsmci_cmdr. ? rxrdy: receiver ready 0 = data has not yet been received since the last read of hsmci_rdr. 1 = data has been received since the last read of hsmci_rdr. ? txrdy: transmit ready 0 = the last data written in hsmci_tdr has not yet been transferred in the shift register. 1 = the last data written in hsmci_tdr has been transferred in the shift register. ? blke: data block ended this flag must be used only for write operations. 0 = a data block transfer is not yet finished. cleared when reading the hsmci_sr. 1 = a data block transfer has ended, including the crc16 status transmission. the flag is set for each transmitted crc status. refer to the mmc or sd sp ecification for more details concerning the crc status. ? dtip: data transfer in progress 0 = no data transfer in progress. 1 = the current data tran sfer is still in progress, including crc16 calculatio n. cleared at the end of the crc16 calculation. ? notbusy: hsmci not busy this flag must be used only for write operations. a block write operation uses a simple busy signalling of the write operat ion duration on the data (dat0) line: during a data transfer block, if the card does not have a free data receive buffer, the card indicates this condition by pulling down the dat a line (dat0) to low. the card stops pulling down the data line as soon as at least one receive buffer for the defined data transfer block length becomes free. the notbusy flag allows to deal with these different states. 31 30 29 28 27 26 25 24 unre ovre ackrcve ackrcv xfrdone fifoempty dmadone blkovre 23 22 21 20 19 18 17 16 cstoe dtoe dcrce rtoe rende rcrce rdire rinde 15 14 13 12 11 10 9 8 CCcsrcvsdiowaitCCC mci_sdioir qa 76543210 C C notbusy dtip blke txrdy rxrdy cmdrdy
805 6438fCatarmC21-jun-10 at91sam9g45 0 = the hsmci is not ready for new data transfer. cleared at the end of the card response. 1 = the hsmci is ready for new data transfer. set when the busy state on the data line has ended. this corresponds to a free internal data receive buffer of the card. refer to the mmc or sd specification for more details concerning the busy behavior. for all the read operations, the notbusy flag is cleared at the end of the host command. for the infinite read multiple blocks, the notbusy flag is set at the end of the st op_transmission host command (cmd12). for the single block reads, the notbusy flag is set at the end of the data read block. for the multiple block reads with pre-defined block count, the notbusy flag is set at the end of the last received data block. ? sdioirqa: sdio interrupt for slot a 0 = no interrupt detected on sdio slot a. 1 = an sdio interrupt on slot a occurred. cleared when reading the hsmci_sr. ? sdiowait: sdio read wait operation status 0 = normal bus operation. 1 = the data bus has entered io wait state. ? csrcv: ce-ata comple tion signal received 0 = no completion signal received since last status read operation. 1 = the device has issued a command completion signal on the command line. cleared by reading in the hsmci_sr register. ? rinde: response index error 0 = no error. 1 = a mismatch is detected between the command index sent and the response index received. cleared when writing in the hsmci_cmdr. ? rdire: response direction error 0 = no error. 1 = the direction bit from card to host in the response has not been detected. ? rcrce: response crc error 0 = no error. 1 = a crc7 error has been detected in the response. cleared when writing in the hsmci_cmdr. ? rende: response end bit error 0 = no error. 1 = the end bit of the response has not been detected. cleared when writing in the hsmci_cmdr. ? rtoe: response time-out error 0 = no error. 1 = the response time-out set by maxlat in the hs mci_cmdr has been exceeded. cleared when writing in the hsmci_cmdr.
806 6438fCatarmC21-jun-10 at91sam9g45 ? dcrce: data crc error 0 = no error. 1 = a crc16 error has been detected in the last data block. cleared by reading in the hsmci_sr register. ? dtoe: data time-out error 0 = no error. 1 = the data time-out set by dtocyc and dtomul in hsmci_dtor has been exceeded. cleared by reading in the hsmci_sr register. ? cstoe: completion signal time-out error 0 = no error. 1 = the completion signal time-out set by cstocyc an d cstomul in hsmci_cstor has been exceeded. cleared by reading in the hsmci_sr register. cleared by reading in the hsmci_sr register. ? blkovre: dma block overrun error 0 = no error. 1 = a new block of data is received and the dma controller has not started to move the current pending block, a block over- run is raised. cleared by read ing in the hsmci_sr register. ? dmadone: dma transfer done 0 = dma buffer transfer has not completed since the last read of hsmci_sr register. 1 = dma buffer transfer has completed. ? fifoempty: fifo empty flag 0 = fifo contains at least one byte. 1 = fifo is empty. ? xfrdone: transfer done flag 0 = a transfer is in progress. 1 = command register is ready to operate and the data bus is in the idle state. ? ackrcv: boot operatio n acknowledge received 0 = no boot acknowledge received since the last read of the status register. 1 = a boot acknowledge signal has been received. cleared by reading the hsmci_sr register. ? ackrcve: boot operation acknowledge error 0 = no error 1 = corrupted boot acknowledge signal received. ? ovre: overrun 0 = no error. 1 = at least one 8-bit received data has been lost (not read). cleared when sending a new data transfer command. when ferrctrl in hsmci_cfg is set to 1, ovre becomes reset after read.
807 6438fCatarmC21-jun-10 at91sam9g45 ? unre: underrun 0 = no error. 1 = at least one 8-bit data has been sent without valid inform ation (not written). cleared when sending a new data transfer command or when setting ferrctrl in hsmci_cfg to 1 . when ferrctrl in hsmci_cfg is set to 1, unre becomes reset after read.
808 6438fCatarmC21-jun-10 at91sam9g45 36.13.13 hsmci interrupt enable register name: hsmci_ier addresses: 0xfff80044 (0), 0xfffd0044 (1) access: write-only ? cmdrdy: command ready interrupt enable ? rxrdy: receiver ready interrupt enable ? txrdy: transmit ready interrupt enable ? blke: data block ended interrupt enable ? dtip: data transfer in progress interrupt enable ? notbusy: data not busy interrupt enable ? sdioirqa: sdio interrupt for slot a interrupt enable ? sdiowait: sdio read wait operation status interrupt enable ? csrcv: completion signal received interrupt enable ? rinde: response index error interrupt enable ? rdire: response direction error interrupt enable ? rcrce: response crc error interrupt enable ? rende: response end bit error interrupt enable ? rtoe: response time-out error interrupt enable ? dcrce: data crc error interrupt enable ? dtoe: data time-out error interrupt enable ? cstoe: completion signal timeout error interrupt enable ? blkovre: dma block overrun error interrupt enable ? dmadone: dma transfer completed interrupt enable ? fifoempty: fifo empty interrupt enable ? xfrdone: transfer done interrupt enable 31 30 29 28 27 26 25 24 unre ovre ackrcve ackrcv xfrdone fifoempty dmadone blkovre 23 22 21 20 19 18 17 16 cstoe dtoe dcrce rtoe rende rcrce rdire rinde 15 14 13 12 11 10 9 8 CCcsrcvsdiowaitCCCmci_sdioirqa 76543210 C C notbusy dtip blke txrdy rxrdy cmdrdy
809 6438fCatarmC21-jun-10 at91sam9g45 ? ackrcv: boot acknowle dge interrupt enable ? ackrcve: boot acknowledge error interrupt enable ? ovre: overrun interrupt enable ? unre: underrun interrupt enable 0 = no effect. 1 = enables the corresponding interrupt.
810 6438fCatarmC21-jun-10 at91sam9g45 36.13.14 hsmci interrupt disable register name: hsmci_idr addresses: 0xfff80048 (0), 0xfffd0048 (1) access: write-only ? cmdrdy: command ready interrupt disable ? rxrdy: receiver ready interrupt disable ? txrdy: transmit ready interrupt disable ? blke: data block ended interrupt disable ? dtip: data transfer in progress interrupt disable ? notbusy: data not busy interrupt disable ? sdioirqa: sdio interrupt for slot a interrupt disable ? sdiowait: sdio read wait operation status interrupt disable ? csrcv: completion signal received interrupt disable ? rinde: response index error interrupt disable ? rdire: response direction error interrupt disable ? rcrce: response crc error interrupt disable ? rende: response end bit error interrupt disable ? rtoe: response time-out error interrupt disable ? dcrce: data crc error interrupt disable ? dtoe: data time-out error interrupt disable ? cstoe: completion signal time out error interrupt disable ? blkovre: dma block overrun error interrupt disable ? dmadone: dma transfer co mpleted interrupt disable ? fifoempty: fifo empty interrupt disable ? xfrdone: transfer done interrupt disable 31 30 29 28 27 26 25 24 unre ovre ackrcve ackrcv xfrdone fifoempty dmadone blkovre 23 22 21 20 19 18 17 16 cstoe dtoe dcrce rtoe rende rcrce rdire rinde 15 14 13 12 11 10 9 8 CCcsrcvsdiowaitCCCmci_sdioirqa 76543210 C C notbusy dtip blke txrdy rxrdy cmdrdy
811 6438fCatarmC21-jun-10 at91sam9g45 ? ackrcv: boot acknowle dge interrupt disable ? ackrcve: boot acknowledge error interrupt disable ? ovre: overrun interrupt disable ? unre: underrun in terrupt disable 0 = no effect. 1 = disables the corresponding interrupt.
812 6438fCatarmC21-jun-10 at91sam9g45 36.13.15 hsmci interrupt mask register name: hsmci_imr addresses: 0xfff8004c (0), 0xfffd004c (1) access: read-only ? cmdrdy: command ready interrupt mask ? rxrdy: receiver ready interrupt mask ? txrdy: transmit ready interrupt mask ? blke: data block ended interrupt mask ? dtip: data transfer in progress interrupt mask ? notbusy: data not busy interrupt mask ? sdioirqa: sdio interrupt for slot a interrupt mask ? sdiowait: sdio read wait operation status interrupt mask ? csrcv: completion signal received interrupt mask ? rinde: response index error interrupt mask ? rdire: response direction error interrupt mask ? rcrce: response crc error interrupt mask ? rende: response end bit error interrupt mask ? rtoe: response time-out error interrupt mask ? dcrce: data crc error interrupt mask ? dtoe: data time-out error interrupt mask ? cstoe: completion signal time-out error interrupt mask ? blkovre: dma block overrun error interrupt mask ? dmadone: dma transfer completed interrupt mask ? fifoempty: fifo empty interrupt mask ? xfrdone: transfer done interrupt mask 31 30 29 28 27 26 25 24 unre ovre ackrcve ackrcv xfrdone fifoempty dmadone blkovre 23 22 21 20 19 18 17 16 cstoe dtoe dcrce rtoe rende rcrce rdire rinde 15 14 13 12 11 10 9 8 CCcsrcvsdiowaitCCCmci_sdioirqa 76543210 C C notbusy dtip blke txrdy rxrdy cmdrdy
813 6438fCatarmC21-jun-10 at91sam9g45 ? ackrcv: boot operation acknow ledge received interrupt mask ? ackrcve: boot operation acknowledge error interrupt mask ? ovre: overrun interrupt mask ? unre: underrun interrupt mask 0 = the corresponding interrupt is not enabled. 1 = the corresponding interrupt is enabled.
814 6438fCatarmC21-jun-10 at91sam9g45 36.13.16 hsmci dma co nfiguration register name: hsmci_dma addresses: 0xfff80050 (0), 0xfffd0050 (1) access: read-write ? offset: dma write buffer offset this field indicates the number of discarded bytes when the dma writes the first word of the transfer. ? chksize: dma channel read and write chunk size the chksize field indicates the number of data available when the dma chunk transfer request is asserted. ? dmaen: dma hardware handshaking enable 0 = dma interface is disabled. 1 = dma interface is enabled. note: to avoid unpredictable behavior, dma hardware handshak ing must be disabled when cpu transfers are performed. ? ropt: read optimization with padding 0: blklen bytes are moved from the memory card to the s ystem memory, two dma descriptors are used when the trans- fer size is not a multiple of 4. 1: ceiling(blklen/4) * 4 bytes are moved from the memory card to the system me mory, only one dma descriptor is used. 31 30 29 28 27 26 25 24 CCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCroptCCCdmaen 76543210 C C chksize C C offset chksize value number of data transferred 00 1 01 4 10 8 11 16
815 6438fCatarmC21-jun-10 at91sam9g45 36.13.17 hsmci configuration register name: hsmci_cfg addresses: 0xfff80054 (0), 0xfffd0054 (1) access: read-write ? fifomode: hsmci internal fifo control mode 0 = a write transfer starts when a sufficient amount of data is written into the fifo. when the block length is greater than or equal to 3/4 of the hsmci internal fifo size, then the write transfer starts as soon as half the fifo is filled. when the block length is greater than or equal to half the internal fifo size, then the write trans fer starts as soon as one quarter of the fifo is filled. in other cases, th e transfer starts as soon as the total amount of data is written in the internal fifo. 1 = a write transfer starts as soon as one data is written into the fifo. ? ferrctrl: flow error flag reset control mode 0 = when an underflow/overflow condition flag is set, a new write/read command is needed to reset the flag. 1 = when an underflow/overflow condition flag is set, a read status resets the flag. ? hsmode: high speed mode 0 = default bus timing mode. 1 = if set to one, the host controller outputs command line and data lines on the rising edge of the card clock. the host driver shall check the high speed support in the card registers. ? lsync: synchronize on the last block 0 = the pending command is sent at the end of the current data block. 1 = the pending command is sent at the end of the block transfer when the transfer length is not infinite (block count shall be different from zero). 31 30 29 28 27 26 25 24 CCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCClsyncCCChsmode 76543210 C C C ferrctrl C C C fifomode
816 6438fCatarmC21-jun-10 at91sam9g45 36.13.18 hsmci write protect mode register name: hsmci_wpmr addresses: 0xfff800e4 (0), 0xfffd00e4 (1) access: read-write ? wp_en: write protection enable 0 = disables the write protec tion if wp_key corresponds. 1 = enables the write protection if wp_key corresponds. ? wp_key: write protection key password should be written at value 0x4d4349 (ascii code for hsmci). writing any other value in this field has no effect. 31 30 29 28 27 26 25 24 wp_key (0x4d => m) 23 22 21 20 19 18 17 16 wp_key (0x43 => c) 15 14 13 12 11 10 9 8 wp_key (0x49 => i) 76543210 wp_en
817 6438fCatarmC21-jun-10 at91sam9g45 36.13.19 hsmci write protect status register name: hsmci_wpsr addresses: 0xfff800e8 (0), 0xfffd00e8 (1) access: read-only ? wp_vsrc: write protec tion violation status ? wp_vsrc: write protection violation source 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 wp_vsrc 15 14 13 12 11 10 9 8 wp_vsrc 76543210 ---- wp_vs wp_vs 0000 no write protection violation occurred since the last read of this register (wp_sr) 0001 write protection detected unauthorized attempt to write a control register had occurred (since the last read.) 0010 software reset had been performed while write protection was enabled (since the last read). 0011 both write protection violation and software reset with write protection enabled had occurred since the last read. other value reserved wp_vsrc 0000 no write protection violation occurred since the last read of this register (wp_sr) 0001 write access in hsmci_mr while write protection was enabled (since the last read). 0010 write access in hsmci_dtor while write protection was enabled (since the last read) 0011 write access in hsmci_sdcr while write protection was enabled (since the last read) 0100 write access in hsmci_cstor while write protection was enabled (since the last read) 0101 write access in hsmci_dma while write protection was enabled (since the last read) 0110 write access in hsmci_cfg while write protection was enabled (since the last read) other value reserved
818 6438fCatarmC21-jun-10 at91sam9g45 36.13.20 hsmci fifo memory aperture name: hsmci_fifo access: read-write ? data: data to read or data to write 31 30 29 28 27 26 25 24 data 23 22 21 20 19 18 17 16 data 15 14 13 12 11 10 9 8 data 76543210 data
819 6438fCatarmC21-jun-10 at91sam9g45 37. usb high speed host port (uhphs) 37.1 description the usb high speed host port (uhphs) interfaces the usb with the host application. it han- dles open hci protocol (open host controller interface) as well as enhanced hci protocol (enhanced host controller interface). 37.2 embedded characteristics the at91sam9g45 features usb communication ports as follows: ? 2 ports usb host full speed ohci and high speed ehci ? 1 device high speed usb host port a is directly connec ted to the first utmi transceiver. the host port b is multiplexed with the usb device high speed and connected to the second utmi port. the selection between host port b and usb device high speed is controlled by a the udphs enable bit located in the udphs_ctrl control register. figure 37-1. usb selection ? compliant with enhanced hc i rev 1.0 specification C compliant with usb v2.0 high-spe ed and full-speed specification C supports both high-speed 480mbps and full-speed 12 mbps usb devices ? compliant with open hc i rev 1.0 specification C compliant with usb v2.0 full-s peed and low-speed specification C supports both low-speed 1.5 mbps and full-speed 12 mbps usb devices ? root hub integrated with 2 downstream usb ports ? shared embedded usb transceivers 37.2.1 ehci the usb host port controller is fully compliant with the enhanced hci specification. the usb host port user interface (registers description) can be found in the enhanced hci rev 1.0 specification available on http://www.intel.com/technology/usb/ehcispec.htm . the standard ehci usb stack driver can be easily ported to atmels architecture in the same way all existing class drivers run, without hardware specialization. hs transceiver dma hs usb dma hs ehci fs ohci pa p b hs transceiver 1 0 en_udphs
820 6438fCatarmC21-jun-10 at91sam9g45 37.2.2 ohci the usb host port integrates a root hub and transceivers on downstream ports. it provides sev- eral full-speed half-duplex serial communication ports at a baud rate of 12 mbit/s. up to 127 usb devices (printer, camera, mouse, keyboard , disk, etc.) and the usb hub can be connected to the usb host in the usb tiered star topology. the usb host port controller is fully compliant with the open hci specification. the usb host port user interface (registers description) can be found in the open hci rev 1.0 specification available on http://h18000.www1.hp.com/productinfo/development/openhci.html . the standard ohci usb stack driver can be easily ported to at mels architecture, in th e same way all existing class drivers run without hardware specialization. this means that all standard class devices are automatically detected and available to the users application. as an example, integrating an hid (human interface device) class driver provides a plug & play feature for all usb keyboards and mouses. 37.3 block diagram figure 37-2. block diagram port s/m 1 port s/m 0 usb transceiver hhsdpa hhsdma embedded usb v2.0 high-speed transceiver root hub and host sie list processor block fifo 64 x 8 hci slave block ohci registers root hub registers ahb ed & td regsisters control hci master block data ahb slave master hfsdpa hfsdma usb transceiver hhsdpb hhsdmb hfsdpb hfsdmb ahb ahb slave master hci slave block ehci registers hci master block list processor packet buffer fifo sof generator control data
821 6438fCatarmC21-jun-10 at91sam9g45 access to the usb host operational registers is achieved through the ahb bus slave interface. the open hci host controller and enhanced hci host controller initialize master dma transfers through the ahb bus master interface as follows: ? fetches endpoint descriptors and transfer descriptors ? access to endpoint data from system memory ? access to the hc communication area ? write status and retire transfer descriptor memory access errors (abort, misalignment) lead to an unrecoverable error indicated by the corresponding flag in the host controller operational registers. the usb root hub is integrated in the usb host. several usb downstream ports are available. the number of downstream ports can be determined by the software driver reading the root hubs operational registers. device connection is automatically detected by the usb host port logic. usb physical transceivers are integrated in the product and driven by the root hubs ports. over current protection on ports can be activated by the usb host controller. atmels standard product does not dedicate pads to external over current protection. 37.4 product dependencies 37.4.1 i/o lines hfsdps, hfsdms, hhsdps and hhsdms are not controlled by any pio controllers. the embedded usb high speed physical transceivers are controlled by the usb host controller. 37.5 i/o lines hfsdps, hfsdms, hhsdps and hhsdms are not controlled by any pio controllers. the embedded usb high speed physical transceivers are controlled by the usb host controller. one transceiver is shared with usb device (u dp) high speed. in this case usb host high speed controller uses only port a, ie, th e signals hfsdpa, hfsdma, hhsdpa and hhsdma. the port b is driven by the udp high speed, the output signals are dfsdp, dfsdm, dhsdp and dhsdm. the transceiver is automatically selected fo r device operation once the udp high speed is enabled. 37.5.1 power management the usb host high speed requires a 48 mhz clock for the embedded high-speed transceivers. this clock is provided by th e utmi pll, it is upllck. in case power consumption is saved by stop ping the utmi pll, high-speed operations are not possible. nevertheless, ohci full-speed operati ons remain possible by selecting pllack as the input clock of ohci. the high-speed transceiver returns a 30 mhz clock to the usb host controller. the usb host controller requires 48 mhz and 12 mhz clocks for ohci full-speed operations. these clocks must be generated by a pll with a correct accuracy of 0.25% thanks to usbdiv field.
822 6438fCatarmC21-jun-10 at91sam9g45 thus the usb host peripheral receives three clocks from the power management controller (pmc): the peripheral clock (mck domain), t he uhp48m and the uhp12m (built-in uhp48m divided by four) used by the ohci to interf ace with the bus usb sig nals (recovered 12 mhz domain) in full-speed operations. for high-speed operations, the user has to perform the following: ? enable uhp peripheral clock, bit (1 << at91c_id_uhphs) in pmc_pcer register. ? write ckgr_pllcount field in pmc_uckr register. ? enable upll, bit at91c_ckgr_upllen in pmc_uckr register. ? wait until utmi_pll is locked. locku bit in pmc_sr register ? enable bias, bit at91c_ckgr_biasen in pmc_uckr register. ? select upllck as input clock of ohci part, usbs bit in pmc_usb register. ? program the ohci clocks (uhp48m and uhp1 2m) with usbdiv field in pmc_usb register. usbdiv must be 9 (division by 10) if upllck is selected. ? enable ohci clocks, uhp bit in pmc_scer register. for ohci full-speed operations only, the user has to perform the following: ? enable uhp peripheral clock, bit (1 << at91c_id_uhphs) in pmc_pcer register. ? select pllack as input clock of ohci part, usbs bit in pmc_usb register. ? program the ohci clocks (uhp48m and uhp1 2m) with usbdiv field in pmc_usb register. usbdiv value is to calculated regarding th e pllack value and usb full-speed accuracy. ? enable the ohci clocks, uhp bit in pmc_scer register.
823 6438fCatarmC21-jun-10 at91sam9g45 figure 37-3. uhp clock trees 37.5.2 interrupt the usb host interface has an interrupt line connected to the advanced interrupt controller (aic). handling usb host interrupts requires programming the aic before configuring the uhp hs. utmi transceiver ehci user interface ahb uhp48m ohci user interface usb 2.0 ehci host controller usb 1.1 ohci host controller root hub and host sie port router utmi transceiver upll (480 mhz) 30 mhz 30 mhz uhp12m ohci master interface ehci master interface mck ohci clocks
824 6438fCatarmC21-jun-10 at91sam9g45 37.6 typical connection figure 37-4. board schematic to interface uhp high-speed device controller note: 1. the values shown on the 22k and 15k resistors are only valid for 3v3 supplied pios. pio (vbus detect) hhsdp hhsdm hfsdm hfsdp vbg gnd c rpb : 1f to 10f c rpb 1 4 2 3 39 5% 39 5% 10 pf "a" receptacle 1 = vbus 2 = d- 3 = d+ 4 = gnd shell = shield 15k 22k 6k8 1% (1) (1)
825 6438fCatarmC21-jun-10 at91sam9g45 38. usb high speed device port (udphs) 38.1 description the usb high speed device port (udphs) is comp liant with the universal serial bus (usb), rev 2.0 high speed device specification. each endpoint can be configured in one of several usb transfer types. it can be associated with one, two or three banks of a dual-port ram used to store the current data payload. if two or three banks are used, one dpr bank is read or written by the processor, while the other is read or written by the usb device peripheral. this feature is mandatory for isochronous endpoints. 38.2 embedded characteristics the at91sam9g45 features usb communication ports as follows: ? 2 ports usb host full speed ohci and high speed ehci ? 1 device high speed usb host port a is directly connec ted to the first utmi transceiver. the host port b is multiplexed with the usb device high speed and connected to the second utmi port. the selection between host port b and usb device high speed is controlled by a the udphs enable bit located in the udphs_ctrl control register. figure 38-1. usb selection ? usb v2.0 high-speed compliant, 480 mbits per second ? embedded usb v2.0 utmi+ high-speed transceiver shared with uhp hs. ? embedded 4-kbyte dual-port ram for endpoints ? embedded 6 channels dma controller ? suspend/resume logic ? up to 2 or 3 banks for isochronous and bulk endpoints ? seven endpoints: C endpoint 0: 64 bytes, 1 bank mode C endpoint 1 & 2: 1024 bytes, 2 banks mode, high bandwidth, dma C endpoint 3 & 4: 1024 bytes, 3 banks mode, dma C endpoint 5 & 6: 1024 bytes, 3 banks mode, high bandwidth, dma hs transceiver dma hs usb dma hs ehci fs ohci pa p b hs transceiver 1 0 en_udphs
826 6438fCatarmC21-jun-10 at91sam9g45 note: 1. in isochronous mode (iso), it is preferable that high band width capability is available. the size of internal dpram is 4 kb. suspend and resume are automatically detected by the udphs device, which notifies the pro- cessor by raising an interrupt. table 38-1. udphs endpoint description endpoint # mnemonic nb bank dma high bandwidth max. endpoint size endpoint type 0 ept_0 1 n n 64 control 1 ept_1 2 y y 1024 ctrl/bulk/iso (1) /interrupt 2 ept_2 2 y y 1024 ctrl/bulk/iso (1) /interrupt 3 ept_3 3 y n 1024 ctrl/bulk/iso (1) /interrupt 4 ept_4 3 y n 1024 ctrl/bulk/iso (1) /interrupt 5 ept_5 3 y y 1024 ctrl/bulk/iso (1) /interrupt 6 ept_6 3 y y 1024 ctrl/bulk/iso (1) /interrupt
827 6438fCatarmC21-jun-10 at91sam9g45 38.3 block diagram figure 38-2. block diagram notes: 1. system clock, bit (1 << at91c_id_udphs) in pmc_pcer register. 2. enable udphs clock (peripheral clock) bit at91c_ckgr_upllen in pmc_uckr register. 3. enable bias bit at91c_ckgr_ biasen in pmc_uckr register. 32 bits system clock domain usb clock domain rd/wr/ready apb interface usb2.0 core ept alloc ahb1 dma ahb0 local ahb slave interface master ahb multiplexeur slave dpram utmi 16/8 bits apb bus ahb bus apb bus pmc dp dm dfsdm dfsdp dhsdm dhsdp ctrl status
828 6438fCatarmC21-jun-10 at91sam9g45 38.4 typical connection figure 38-3. board schematic notes: 1. the values shown on the 22k and 15k resistors are only valid with 3v3 supplied pios. pio (vbus detect) dhsdp dhsdm dfsdm dfsdp vbg gnd c rpb :1f to 10f c rpb 1 4 2 3 10 pf "b" receptacle 1 = vbus 2 = d- 3 = d+ 4 = gnd shell = shield 15k 22k 39 5% 39 5% 6k8 1% (1) (1)
829 6438fCatarmC21-jun-10 at91sam9g45 38.5 functional description 38.5.1 usb v2.0 high speed device port introduction the usb v2.0 high speed device port provides communication services between host and attached usb devices. each device is offered with a collection of communication flows (pipes) associated with each endpoint. software on the host communicates with a usb device through a set of communication flows. 38.5.2 usb v2.0 high speed transfer types a communication flow is carried over one of f our transfer types defined by the usb device. a device provides several logical communication pipes with the host. to each logical pipe is associated an endpoint. transfer through a pipe belongs to one of the four transfer types: ? control transfers: used to configure a device at attach time and can be used for other device- specific purposes, including control of other pipes on the device. ? ? bulk data transfers: generated or consumed in relatively large burst quantities and have wide dynamic latitude in transmission constraints. ? ? interrupt data transfers: used for timely but reliable delivery of data, for example, characters or coordinates with human-perceptible echo or feedback response characteristics. ? isochronous data transfers: occupy a prenegotiated amount of usb bandwidth with a prenegotiated delivery latency. (also called streaming real time transfers.) as indicated below, transfers are sequential events carried out on the usb bus. endpoints must be configured according to the transfer type they handle. 38.5.3 usb transfer event definitions a transfer is composed of one or several transactions; table 38-2. usb communication flow transfer direction bandwidth endpoi nt size error detection retrying control bidirectional not guaranteed 8,16,32,64 yes automatic isochronous unidirectional guaranteed 8-1024 yes no interrupt unidirectional not guaranteed 8-1024 yes yes bulk unidirectional not guaranteed 8-512 yes yes table 38-3. usb transfer events control (bidirectional) control transfers (1) ? setup transaction data in transactions status out transaction ? setup transaction data out transactions status in transaction ? setup transaction status in transaction in (device toward host) bulk in transfer ? data in transaction data in transaction interrupt in transfer ? data in transaction data in transaction isochronous in transfer (2) ? data in transaction data in transaction
830 6438fCatarmC21-jun-10 at91sam9g45 notes: 1. control transfer must use endpoints with on e bank and can be aborted using a stall handshake. 2. isochronous transfers must use endpoints configured with two or three banks. an endpoint handles all transactions related to the type of transfer for which it has been configured. 38.5.4 usb v2.0 high speed bus transactions each transfer results in one or more transactions over the usb bus. there are five kinds of transactions flowing across the bus in packets: 1. setup transaction 2. data in transaction 3. data out transaction 4. status in transaction 5. status out transaction figure 38-4. control read and write sequences a status in or out transaction is identical to a data in or out transaction. 38.5.5 endpoint configuration the endpoint 0 is always a control endpoint, it must be programmed and active in order to be enabled when the end of reset interrupt occurs. out (host toward device) bulk out transfer ? data out transaction data out transaction interrupt out transfer ? data out transaction data out transaction isochronous out transfer (2) ? data out transaction data out transaction table 38-3. usb transfer events (continued) control (bidirectional) control transfers (1) ? setup transaction data in transactions status out transaction ? setup transaction data out transactions status in transaction ? setup transaction status in transaction control write setup tx data out tx data out tx data stage control read setup stage setup stage setup tx setup tx no data control data in tx data in tx status stage status stage status in tx status out tx status in tx data stage setup stage status stage
831 6438fCatarmC21-jun-10 at91sam9g45 to configure the endpoints: ? fill the configuration register (udphs_eptcfg) with the endp oint size, direction (in or out), type (ctrl, bulk, it, iso) and the number of banks. ? fill the number of transactions (n b_trans) for isochronous endpoints. note: for control endpoints the direction has no effect. ? verify that the ept_mapd flag is set. this flag is set if the endpoint size and the number of banks are correct compared to the fifo maximum capacity and the maximum number of allowed banks. ? configure control flags of the endpoint and enable it in udphs_eptctlenbx according to udphs endpoint control register on page 876 . control endpoints can generate interrupts and use only 1 bank. all endpoints (except endpoint 0) can be configur ed either as bulk, interrupt or isochronous. see table 38-1. udphs endpoint description . the maximum packet size they can accept corresponds to the maximum endpoint size. note: the endpoint size of 1024 is reserved for isochronous endpoints. the size of the dpram is 4 kb. the dpr is shared by all active endpoints. the memory size required by the active endpoints must not exceed the size of the dpram. size_dpram = size _ept0 + nb_bank_ept1 x size_ept1 + nb_bank_ept2 x size_ept2 + nb_bank_ept3 x size_ept3 + nb_bank_ept4 x size_ept4 + nb_bank_ept5 x size_ept5 + nb_bank_ept6 x size_ept6 +... (refer to 38.6.11 udphs endpoint configuration register ) if a user tries to configure endpoints with a size the sum of which is greater than the dpram, then the ept_mapd is not set. the application has access to the physical block of dpr reserved for the endpoint through a 64 kb logical address space. the physical block of dpr allocated for the endpoint is remapped all along the 64 kb logical address space. the application can write a 64 kb buffer linearly.
832 6438fCatarmC21-jun-10 at91sam9g45 figure 38-5. logical address space for dpr access: configuration examples of udphs_eptctlx ( udphs endpoint control register ) for bulk in endpoint type follow below. ?with dma C auto_valid: automatically validate the packet and switch to the next bank. C ept_enabl: enable endpoint. ? without dma: C tx_bk_rdy: an interrupt is generated after each transmission. C ept_enabl: enable endpoint. configuration examples of bulk out endpoint type follow below. ?with dma C auto_valid: automatically validate the packet and switch to the next bank. C ept_enabl: enable endpoint. ? without dma C rx_bk_rdy: an interrupt is sent after a new packet has been stored in the endpoint fifo. C ept_enabl: enable endpoint. 64 kb ep0 64 kb ep1 64 kb ep2 dpr logical address 8 to 64 b 8 to1024 b 8 to1024 b 8 to1024 b 64 kb ep3 ... 8 to 64 b 8 to 64 b 8 to 64 b ... ... x banks y banks z banks 8 to1024 b 8 to1024 b 8 to1024 b
833 6438fCatarmC21-jun-10 at91sam9g45 38.5.6 transfer with dma usb packets of any length may be transferred when required by the udphs device. these transfers always feature sequential addressing. packet data ahb bursts may be locked on a dma buffer basis for drastic overall ahb bus band- width performance boost with pa ged memories. these clock-cycl e consuming memory row (or bank) changes will then likely not occur, or occu r only once instead of dozens times, during a single big usb packet dma transfer in case another ahb master addresses the memory. this means up to 128-word single-cycle unbroken ahb bursts for bulk endpoints and 256-word sin- gle-cycle unbroken bursts for isochronous endpo ints. this maximum burst length is then controlled by the lowest programmed usb endpoint size (ept_size bit in the udphs_eptcfgx register) and dma size (buff_length bit in the udphs_dmacontrolx register). the usb 2.0 device average throughput may be up to nearly 60 mbytes. its internal slave aver- age access latency decreases as bu rst length increases due to the 0 wait-state side effect of unchanged endpoi nts. if at least 0 wait-state word burst capability is also pr ovided by the exter- nal dma ahb bus slaves, eac h of both dma ahb busses need less than 50% bandwidth allocation for full usb 2.0 bandwidth usage at 30 mhz, and less than 25% at 60 mhz. the udphs dma channel transfer descriptor is described in udphs dma channel transfer descriptor on page 887 . note: in case of debug, be careful to address the dma to an sram address even if a remap is done. figure 38-6. example of dma chained list: data buff 1 data buff 2 data buff 3 memory area transfer descriptor next descriptor address dma channel address dma channel control transfer descriptor next descriptor address dma channel address dma channel control transfer descriptor next descriptor address dma channel address dma channel control udphs registers (current transfer descriptor) udphs next descriptor dma channel address dma channel control null
834 6438fCatarmC21-jun-10 at91sam9g45 38.5.7 transfer without dma important. if the dma is not to be used, it is necessary that it be disabled because otherwise it can be enabled by previous versions of software without warning . if this should occur, the dma can process data before an interrupt without knowledge of the user. the recommended means to disable dma is as follows: // reset ip udphs at91c_base_udphs->udphs_ctrl &= ~at91c_udphs_en_udphs; at91c_base_udphs->udphs_ctrl |= at91c_udphs_en_udphs; // with or without dma !!! for( i=1; i<=((at91c_base_udphs->udphs_ipfeatures & at91c_udphs_dma_channel_nbr)>>4); i++ ) { // reset endpoint canal dma: // dma stop channel command at91c_base_udphs->udphs_dma[i].udphs_dmacontrol = 0; // stop command // disable endpoint at91c_base_udphs->udphs_ept[i].udphs_eptctldis |= 0xffffffff; // reset endpoint config at91c_base_udphs->udphs_ept[i].udphs_eptctlcfg = 0; // reset dma channel (buff count and control field) at91c_base_udphs->udphs_dma[i].udphs_dmacontrol = 0x02; // non stop command // reset dma channel 0 (stop) at91c_base_udphs->udphs_dma[i].udphs_dmacontrol = 0; // stop command // clear dma channel status (read the register for clear it) at91c_base_udphs->udphs_dma[i].udphs_dmastatus = at91c_base_udphs->udphs_dma[i].udphs_dmastatus; } 38.5.8 handling transactions with usb v2.0 device peripheral 38.5.8.1 setup transaction the setup packet is valid in the dpr while rx_s etup is set. once rx_setup is cleared by the application, the udphs accepts the next packets sent over the device endpoint. when a valid setup packet is accepted by the udphs: ? the udphs device automatically acknowledges the setup packet (sends an ack response) ? payload data is written in the endpoint ? sets the rx_setup interrupt ? the byte_count field in the udphs_eptstax register is updated an endpoint interrupt is generated while rx_ setup in the udphs_eptstax register is not cleared. this interrupt is carried out to the microcontroller if interrupts are enabled for this endpoint.
835 6438fCatarmC21-jun-10 at91sam9g45 thus, firmware must detect rx_setup polling udphs_eptstax or catching an interrupt, read the setup packet in the fifo, then clear the rx_setup bit in the udphs_eptclrsta register to acknowledge the setup stage. if stall_snt was set to 1, then this bit is automatically reset when a setup token is detected by the device. then, the device still accepts the setup stage. (see section 38.5.8.15 stall on page 846 ). 38.5.8.2 nyet nyet is a high speed only handshake. it is retu rned by a high speed endpoint as part of the ping protocol. high speed devices must support an improved nak mechanism for bulk out and control end- points (except setup stage). this mechanism allows the device to tell the host whether it has sufficient endpoint space for the next out transfe r (see usb 2.0 spec 8.5.1 nak limiting via ping flow control). the nyet/ack response to a high speed bulk out transfer and the ping response are auto- matically handled by hardware in the udphs_ept ctlx register (except when the user wants to force a nak response by using the nyet_dis bit). if the endpoint responds instead to the out/data transaction with an nyet handshake, this means that the endpoint accepted the data but does not have room for another data payload. the host controller must return to using a ping token until the endpoint indicates it has space available. figure 38-7. nyet example with two endpoint banks 38.5.8.3 data in 38.5.8.4 bulk in or interrupt in data in packets are sent by the device during the data or the status stage of a control transfer or during an (interrupt/bulk/isochronous) in transfer. data buffers are sent packet by packet under the control of the application or under the control of the dma channel. there are three ways for an application to transfer a buffer in several packets over the usb: ? packet by packet (see 38.5.8.5 below) ? 64 kb (see 38.5.8.5 below) ? dma (see 38.5.8.6 below) 38.5.8.5 bulk in or interrupt in: sending a packet under application control (device to host) the application can write one or several banks. t = 0 t = 125 s t = 250 s t = 375 s t = 500 s t = 625 s data 0 ack data 1 nyet ping ack data 0 nyet ping nack ping ack bank 1 bank 0 bank 0 bank 1 bank 0 bank 1 bank 0 bank 1 bank 0 bank 1 bank 0 bank 1 bank 0 bank 1 e f f e f e' f e f f e' f e f e: empty e': begin to empty f: full
836 6438fCatarmC21-jun-10 at91sam9g45 a simple algorithm can be used by the application to send packets regardless of the number of banks associated to the endpoint. algorithm description for each packet: ? the application waits for tx_pk_rdy flag to be cleared in the udphs_eptstax register before it can perform a write access to the dpr. ? the application writes one usb packet of data in the dpr through the 64 kb endpoint logical memory window. ? the application sets tx_pk_rdy flag in the udphs_eptsetstax register. the application is notified that it is possible to write a new packet to the dpr by the tx_pk_rdy interrupt. this interrupt can be enabled or masked by setting the tx_pk_rdy bit in the udphs_eptctlenb/udp hs_eptctldis register. algorithm description to fill several packets: using the previous algorithm, the application is interrupted for each packet. it is possible to reduce the application overhead by writing linearly several banks at the same time. the auto_valid bit in the udphs_eptctlx must be set by writing the auto_valid bit in the udphs_eptctlenbx register. the auto-valid-bank mechanism allows the transfer of data (in and out) without the interven- tion of the cpu. this means that bank validation (set tx_pk_rdy or clear the rx_bk_rdy bit) is done by hardware. ? the application checks the busy_bank_sta field in the udphs_eptstax register. the application must wait that at least one bank is free. ? the application writes a number of bytes inferior to the number of free dpr banks for the endpoint. each time the application writes the last byte of a bank, the tx_pk_rdy signal is automatically set by the udphs. ? if the last packet is incomplete (i.e., the last byte of the bank has not been written) the application must set the tx_pk_rdy bit in the udphs_eptsetstax register. the application is notified that all banks are free, so that it is possible to write another burst of packets by the busy_bank interrupt. this interrupt can be enabled or masked by setting the busy_bank flag in the udphs_eptctle nb and udphs_eptctldis registers. this algorithm must not be used for isochronous transfer. in this case, the ping-pong mechanism does not operate. a zero length packet can be sent by setting just the tx_pktrdy flag in the udphs_eptsetstax register. 38.5.8.6 bulk in or interrupt in: sending a buffer using dma (device to host) the udphs integrates a dma host controller. this dma controller can be used to transfer a buf- fer from the memory to the dpr or from the dpr to the processor memory under the udphs control. the dma can be used for all transfer types except control transfer. example dma configuration: 1. program udphs_dmaaddress x with the addr ess of the buffer that should be transferred. 2. enable the interrupt of the dma in udphs_ien 3. program udphs_ dmacontrolx:
837 6438fCatarmC21-jun-10 at91sam9g45 C size of buffer to send: size of the buffer to be sent to the host. C end_b_en: the endpoint can validate the packet (according to the values programmed in the auto_valid and shrt_pckt fields of udphs_eptctlx.) (see udphs endpoint control register on page 876 and figure 38-12. autovalid with dma ) C end_buffit: generate an interrupt when the buff_count in udphs_dmastatusx reaches 0. C chann_enb: run and stop at end of buffer the auto-valid-bank mechanism allows the transfer of data (in & out) without the intervention of the cpu. this means that bank validation (s et tx_pk_rdy or clear the rx_bk_rdy bit) is done by hardware. a transfer descriptor can be used. instead of programming the register directly, a descriptor should be programmed and the address of this descriptor is then given to udphs_dmanxtdsc to be processed after setting the ldnxt_dsc field (load next descrip- tor now) in udphs_dmacontrolx register. the structure that defines this transfer descriptor must be aligned. each buffer to be transferred must be described by a dma transfer descriptor (see udphs dma channel transfer descriptor on page 887 ). transfer descriptors are chained. before exe- cuting transfer of the buffer, the udphs may fetch a new transfer descriptor from the memory address pointed by the udphs_dmanxtdscx regi ster. once the transfer is complete, the transfer status is updated in the udphs_dmastatusx register. to chain a new transfer descriptor with the current dma transfer, the dma channel must be stopped. to do so, intdis_dma and tx_bk_rdy may be set in the udphs_eptctlenbx register. it is also possible for the application to wait for the completion of all transfers. in this case the ldnxt_dsc field in the last transfer descriptor udphs_dmacontrolx register must be set to 0 and chann_enb set to 1. then the application can chain a new transfer descriptor. the intdis_dma can be used to stop the current dma transfer if an enabled interrupt is trig- gered. this can be used to stop dma transfers in case of errors. the application can be notified at the end of any buffer transfer (enb_buffit bit in the udphs_dmacontrolx register).
838 6438fCatarmC21-jun-10 at91sam9g45 figure 38-8. data in transfer for endpoint with one bank figure 38-9. data in transfer for endpoint with two banks usb bus packets fifo content tx_complt flag (udphs_eptstax) tx_pk_rdy flag (udphs_eptstax) prevous data in tx microcontroller loads data in fifo data is sent on usb bus interrupt pending set by firmware cleared by hardware set by the firmware cleared by hardware interrupt pending cleared by firmware dpr access by firmware dpr access by hardware cleared by firmware payload in fifo set by hardware data in 2 token in nak ack data in 1 token in token in ack data in 1 load in progress data in 2 read by usb device read by udphs device fifo (dpr) bank 0 tx_complt flag (udphs_eptstax) interrupt cleared by firmware virtual tx_pk_rdy bank 1 (udphs_eptstax) ack token in ack set by firmware, data payload written in fifo bank 1 cleared by hardware data payload fully transmitted token in usb bus packets set by hardware set by hardware set by firmware, data payload written in fifo bank 0 written by fifo (dpr) bank1 microcontroller written by microcontroller written by microcontroller microcontroller load data in bank 0 microcontroller load data in bank 1 udphs device send bank 0 microcontroller load data in bank 0 udphs device send bank 1 interrupt pending data in data in cleared by hardware switch to next bank virtual tx_pk_rdy bank 0 (udphs_eptstax)
839 6438fCatarmC21-jun-10 at91sam9g45 figure 38-10. data in followed by status out transfer at the end of a control transfer note : a nak handshake is always generated at the first status stage token. figure 38-11. data out followed by status in transfer note : before proceeding to the status stage, the software should determine that there is no risk of extra data from the host (data stage). if not certain (non-predictable data stage length), then the software should wait for a nak-in interrupt before proceeding to the status stage. this pre- caution should be taken to av oid collision in the fifo. token out data in token in ack ack data out (zlp) rx_bk_rdy (udphs_eptstax) tx_complt (udphs_eptstax) set by hardware set by hardware usb bus packets cleared by firmware cleared by firmware device sends a status out to host device sends the last data payload to host interrupt pending token out ack data out (zlp) token in ack data out token out ack data in usb bus packets rx_bk_rdy (udphs_eptstax) cleared by firmware set by hardware clear by hardware tx_pk_rdy (udphs_eptstax) set by firmware host sends the last data payload to the device device sends a status in to the host interrupt pending
840 6438fCatarmC21-jun-10 at91sam9g45 figure 38-12. autovalid with dma note: in the illustration above autovalid validates a bank as full, although this might not be the case, in order to continue pr ocessing data and to send to dma. 38.5.8.7 isochronous in isochronous-in is used to transmit a stream of data whose timing is implied by the delivery rate. isochronous transfer provides periodic, continuous communication between host and device. it guarantees bandwidth and low latencies appropriate for telephony, audio, video, etc. if the endpoint is not available (tx_pk_rdy = 0), then the device does not answer to the host. an err_fl_iso interrupt is generated in the udphs_eptstax register and once enabled, then sent to the cpu. the stall_snt command bit is not used for an iso-in endpoint. 38.5.8.8 high bandwidth isochronous endpoint handling: in example for high bandwidth isochronous endpoints, the dma can be programmed with the number of transactions (buff_length field in udphs_ dmacontrolx) and the system should provide bank 0 bank 1 bank 0 bank (usb) write write bank 0 write bank 1 write bank 0 bank 0 bank (system) bank 1 bank 0 bank 1 virtual tx_pk_rdy bank 0 virtual tx_pk_rdy bank 1 tx_pk_rdy (virtual 0 & virtual 1) bank 0 is full bank 1 is full bank 0 is full in data 0 in data 1 in data 0 bank 1 bank 1 bank 0
841 6438fCatarmC21-jun-10 at91sam9g45 the required number of packets per microframe, otherwise, the host will notice a sequencing problem. a response should be made to the first token in recognized inside a microframe under the fol- lowing conditions: ? if at least one bank has been validated, the correct datax corresponding to the programmed number of transactions per microframe (nb_trans) should be answered. in case of a subsequent missed or corrupted token in inside the microframe, the usb 2.0 core available data bank(s) that should normally have been transmitted during that microframe shall be flushed at its end. if this flush occurs, an er ror condition is flagg ed (err_flush is set in udphs_eptstax). ? if no bank is validated yet, the default data0 zlp is answered and underflow is flagged (err_fl_iso is set in udphs_ eptstax). then, no data bank is flushed at microframe end. ? if no data bank has been validated at the time when a response should be made for the second transaction of nb_trans = 3 transac tions microframe, a data1 zlp is answered and underflow is flagged (err_fl_iso is set in udphs_eptstax). if and only if remaining untransmitted banks for that microframe are available at its end, they are flushed and an error condition is flagged (err_flus h is set in udphs_eptstax). ? if no data bank has been validated at the time when a response should be made for the last programmed transaction of a microframe, a data0 zlp is answered and underflow is flagged (err_fl_iso is set in udphs_eptstax). if and only if the remaining untransmitted data bank for that microframe is available at its end, it is flushed and an error condition is flagged (err_flush is set in udphs_eptstax). ? if at the end of a microframe no valid token in has been recognized, no data bank is flushed and no error condition is reported. at the end of a microframe in which at least one data bank has been transmitted, if less than nb_trans banks have been validated for that microframe, an error condition is flagged (err_trans is set in udphs_eptstax). cases of error (in udphs_eptstax) ? err_fl_iso: there was no data to transmit inside a microframe, so a zlp is answered by default. ? err_flush: at least one packet has been sent inside the microframe, but the number of token in received is lesser than the number of transactions actually validated (tx_bk_rdy) and likewise with the nb_trans programmed. ? err_trans: at least one packet has been sent inside the microframe, but the number of token in received is lesser than the number of programmed nb_trans transactions and the packets not requested were not validated. ? err_fl_iso + err_flush: at least one packet has been sent inside the microframe, but the data has not been validated in time to answer one of the following token in. ? err_fl_iso + err_trans: at least one packet has been sent inside the microframe, but the data has not been validated in time to answer one of the following token in and the data can be discarded at the microframe end. ? err_flush + err_trans: the first token in has been answered and it was the only one received, a second bank has been validated but not the third, whereas nb_trans was waiting for three transactions.
842 6438fCatarmC21-jun-10 at91sam9g45 ? err_fl_iso + err_flush + err_trans: the first token in has been treated, the data for the second token in was not available in time, but the second bank has been validated before the end of the microframe. the third bank has not been validated, but three transactions have been set in nb_trans. 38.5.8.9 data out 38.5.8.10 bulk out or interrupt out like data in, data out packets are sent by the host during the data or the status stage of con- trol transfer or during an interrupt/bulk/isochronous out transfer. data buffers are sent packet by packet under the control of the application or under the control of the dma channel. 38.5.8.11 bulk out or interrupt out: receiving a packet under application control (host to device) algorithm description for each packet: ? the application enables an interrupt on rx_bk_rdy. ? when an interrupt on rx_bk_rdy is received , the application knows that udphs_eptstax register byte_count bytes have been received. ? the application reads the byte_count bytes from the endpoint. ? the application clears rx_bk_rdy. note: if the application does not know the size of the transfer, it may not be a good option to use auto_valid. because if a zero-length-packet is received, the rx_bk_rdy is automatically cleared by the auto_valid hardwa re and if the endpoint interrupt is triggered, the software will not find its originating flag when reading the udphs_eptstax register. algorithm to fill several packets: ? the application enables the interrupts of busy_bank and auto_valid. ? when a busy_bank interrupt is received, the application knows that all banks available for the endpoint have be en filled. thus, the application can read all banks available. if the application doesnt know the size of t he receive buffer, instead of using the busy_bank interrupt, the application must use rx_bk_rdy. 38.5.8.12 bulk out or interrupt out: sending a buffer using dma (host to device) to use the dma setting, the auto_valid field is mandatory. see 38.5.8.6 bulk in or interrupt in: sending a buffer using dma (device to host) for more information. dma configuration example: 1. first program udphs_dmaaddressx with the address of the buff er that should be transferred. 2. enable the interrupt of the dma in udphs_ien 3. program the dma channe lx control register: C size of buffer to be sent. C end_b_en: can be used for out packet truncation (discarding of unbuffered packet data) at the end of dma buffer.
843 6438fCatarmC21-jun-10 at91sam9g45 C end_buffit: generate an interrupt when buff_count in the udphs_dmastatusx register reaches 0. C end_tr_en: end of transfer enable, the udphs device can put an end to the current dma transfer, in case of a short packet. C end_tr_it: end of transfer interrupt enable, an interrupt is sent after the last usb packet has been transferred by the dma, if the usb transfer ended with a short packet. (beneficial when the receive size is unknown.) C chann_enb: run and stop at end of buffer. for out transfer, the bank will be automatical ly cleared by hardware when the application has read all the bytes in the bank (the bank is empty). note: when a zero-length-packet is received, rx_bk_rdy bit in udphs_eptstax is cleared automatically by auto_valid, and the application knows of the end of buffer by the presence of the end_tr_it. note: if the host sends a zero-length packet, and the endpoint is free, then the device sends an ack. no data is written in the endpoint, the rx_by_rdy interrupt is generated, and the byte_count field in udphs_eptstax is null. figure 38-13. data out transfer for endpoint with one bank ack token out nak token out ack token out data out 1 usb bus packets rx_bk_rdy set by hardware cleared by firmware, data payload written in fifo fifo (dpr) content written by udphs device microcontroller read data out 1 data out 1 data out 2 host resends the next data payload microcontroller transfers data host sends data payload data out 2 data out 2 host sends the next data payload written by udphs device (udphs_eptstax) interrupt pending
844 6438fCatarmC21-jun-10 at91sam9g45 figure 38-14. data out transfer for an endpoint with two banks 38.5.8.13 high bandwidth isochronous endpoint out figure 38-15. bank management, example of three transactions per microframe usb 2.0 supports individual high speed isochronous endpoints that require data rates up to 192 mb/s (24 mb/s): 3x1024 data bytes per microframe. to support such a rate, two or three banks ma y be used to buffer the three consecutive data packets. the microcontroller (or the dma) should be able to empty the banks very rapidly (at least 24 mb/s on average). nb_trans field in udphs_eptcfgx register = number of transactions per microframe. if nb_trans > 1 then it is high bandwidth. token out ack data out 3 token out data out 2 token out data out 1 data out 1 data out 2 data out 2 ack cleared by firmware usb bus packets virtual rx_bk_rdy bank 0 virtual rx_bk_rdy bank 1 set by hardware data payload written in fifo endpoint bank 1 fifo (dpr) bank 0 bank 1 write by udphs device write in progress read by microcontroller read by microcontroller set by hardware, data payload written in fifo endpoint bank 0 host sends first data payload microcontroller reads data 1 in bank 0, host sends second data payload microcontroller reads data 2 in bank 1, host sends third data payload cleared by firmware write by hardware fifo (dpr) (udphs_eptstax) interrupt pending interrupt pending rx_bk_rdy = (virtual bank 0 | virtual bank 1) data out 1 data out 3 m data 0 m data 0 m data 1 data 2 data 2 m data 1 t = 0 t = 52.5 s (40% of 125 s) rx_bk_rdy t = 125 s rx_bk_rdy usb line read bank 3 read bank 2 read bank 1 read bank 1 usb bus transactions microcontroller fifo (dpr) access
845 6438fCatarmC21-jun-10 at91sam9g45 example: ? if nb_trans = 3, the sequence should be either Cmdata0 C mdata0/data1 C mdata0/data1/data2 ? if nb_trans = 2, the sequence should be either Cmdata0 C mdata0/data1 ? if nb_trans = 1, the sequence should be C data0 38.5.8.14 isochronous endpoint handling: out example the user can ascertain the bank status (free or busy), and the toggle sequencing of the data packet for each bank with the udphs_eptstax register in the three bit fields as follows: ? togglesq_sta: pid of the data stored in the current bank ? current_bank: number of the bank currently being accessed by the microcontroller. ? busy_bank_sta: number of busy bank this is particularly useful in case of a missing data packet. if the inter-packet delay between the out token and the data is greater than the usb standard, then the iso-out transaction is ignored. (payload data is not written, no interrupt is generated to the cpu.) if there is a data crc (cyclic redundancy check) error, the payload is, none the less, written in the endpoint. the err_criso flag is set in udphs_eptstax register. if the endpoint is already full, the packet is not written in the dpram. the err_fl_iso flag is set in udphs_eptstax. if the payload data is greater than the maximum size of the endpoint, then the err_ovflw flag is set. it is the task of the cpu to manage this error. the data packet is written in the endpoint (except the extra data). if the host sends a zero length packet, and the endpoint is free, no data is written in the end- point, the rx_bk_rdy flag is set, and the byt e_count field in udphs_eptstax register is null. the frcestall command bit is unused for an isochonous endpoint. otherwise, payload data is written in the endpoint, the rx_bk_rdy interrupt is generated and the byte_count in udphs_eptst ax register is updated.
846 6438fCatarmC21-jun-10 at91sam9g45 38.5.8.15 stall stall is returned by a function in response to an in token or after the data phase of an out or in response to a ping transaction. stall indicates that a function is unable to transmit or receive data, or that a control pipe request is not supported. ?out to stall an endpoint, set the frcestall bit in udphs_eptsetstax register and after the stall_snt flag has been set, set the toggle_seg bit in the udphs_eptclrstax register. ?in set the frcestall bit in udphs_eptsetstax register. figure 38-16. stall handshake data out transfer figure 38-17. stall handshake data in transfer token out stall pid data out usb bus packets cleared by firmware set by firmware frcestall stall_snt set by hardware interrupt pending cleared by firmware token in stall pid usb bus packets cleared by firmware set by firmware frcestall stall_snt set by hardware cleared by firmware interrupt pending
847 6438fCatarmC21-jun-10 at91sam9g45 38.5.9 speed identification the high speed reset is managed by the hardware. at the connection, the host makes a reset which could be a classic reset (full speed) or a high speed reset. at the end of the re set process (full or high), the endreset interrupt is generated. then the cpu should read the speed bit in udphs_intstax to ascertain the speed mode of the device. 38.5.10 usb v2.0 high speed global interrupt interrupts are defined in section 38.6.3 udphs interrupt enable register (udphs_ien) and in section 38.6.4 udphs interrupt status register (udphs_intsta). 38.5.11 endpoint interrupts interrupts are enabled in udphs_ien (see section 38.6.3 udphs interrupt enable register ) and individually masked in udphs_eptctlenbx (see section 38.6.12 udphs endpoint control enable register ). . table 38-4. endpoint interrupt source masks shrt_pckt short packet interrupt busy_bank busy bank interrupt nak_out nakout interrupt nak_in/err_flush nakin/error flush interrupt stall_snt/err_criso/err_nb_tra stall sent/crc error/number of transaction error interrupt rx_setup/err_fl_iso received setup/error flow interrupt tx_pk_rd /err_trans tx packet read/transaction error interrupt tx_complt transmitted in data complete interrupt rx_bk_rdy received ou t data interrupt err_ovflw overflow error interrupt mdata_rx mdata interrupt datax_rx datax interrupt
848 6438fCatarmC21-jun-10 at91sam9g45 figure 38-18. udphs interrupt control interface det_suspd micro_sof int_sof endreset wake_up endofrsm upstr_res usb global it sources ept0 it sources busy_bank nak_out (udphs_eptctlenbx) nak_in/err_flush stall_snt/err_criso/err_nbtra rx_setup/err_fl_iso tx_bk_rdy/err_trans tx_complt rx_bk_rdy err_ovflw mdata_rx datax_rx (udphs_ien) ept1-6 it sources global it mask global it sources ep mask ep sources (udphs_ien) ept_0 ep mask ep sources (udphs_ien) ept_x (udphs_eptctlx) intdis_dma dma ch x (udphs_dmacontrolx) en_buffit end_tr_it desc_ld_it mask mask mask (udphs_ien) dma_x shrt_pckt husb2dev interrupt disable dma channelx request
849 6438fCatarmC21-jun-10 at91sam9g45 38.5.12 power modes 38.5.12.1 controllin g device states a usb device has several possible states. refer to chapter 9 (usb device framework) of the universal serial bus specification, rev 2.0. figure 38-19. udphs device state diagram movement from one state to another depends on the usb bus state or on standard requests sent through control transactions via the default endpoint (endpoint 0). after a period of bus inactivity, the us b device enters suspend mode. accepting sus- pend/resume requests from the usb host is mandatory. constraints in suspend mode are very strict for bus-powered applications; devices may not consume more than 500 a on the usb bus. while in suspend mode, the host may wake up a de vice by sending a resume signal (bus activ- ity) or a usb device may send a wake-up request to the host, e.g., waking up a pc by moving a usb mouse. the wake-up feature is not mandatory for all devices and must be negotiated with the host. attached suspended suspended suspended suspended hub reset or deconfigured hub configured bus inactive bus activity bus inactive bus activity bus inactive bus activity bus inactive bus activity reset reset address assigned device deconfigured device configured powered default address configured power interruption
850 6438fCatarmC21-jun-10 at91sam9g45 38.5.12.2 not powered state self powered devices can detect 5v vbus using a pio. when the device is not connected to a host, device power consumption can be reduced by the detach bit in udphs_ctrl. dis- abling the transceiver is automatically done. hsdm, hsdp, fsdp and fsdp lines are tied to gnd pull-downs integrated in the hub downstream ports. 38.5.12.3 entering attached state when no device is connected, the usb fsdp and fsdm signals are tied to gnd by 15 k pull- downs integrated in the hub downstream por ts. when a device is attached to an hub down- stream port, the device connects a 1.5 k pull-up on fsdp. the usb bus line goes into idle state, fsdp is pulled-up by the device 1.5 k resistor to 3.3v and fsdm is pulled-down by the 15 k resistor to gnd of the host. after pull-up connection, the device enters the powered state. the transceiver remains disabled until bus activity is detected. in case of low power consumption need, the device can be stopped. when the device detects the vbus, the software must enable the usb transceiver by enabling the en_udphs bit in udphs_ctrl register. the software can detach the pull-up by setting detach bit in udphs_ctrl register. 38.5.12.4 from powered state to default state (reset) after its connection to a usb host, the usb device waits for an end-of-bus reset. the unmasked flag endreset is set in the udphs_ien re gister and an inte rrupt is triggered. once the endreset interrupt has be en triggered, the devi ce enters default st ate. in this state, the udphs software must: ? enable the default endpoint, setting the ept_enabl flag in the udphs_eptctlenb[0] register and, optionally, enabling the interrupt for endpoint 0 by writing 1 in ept_0 of the udphs_ien register. the enumeration then begins by a control transfer. ? configure the interrupt mask register which has been reset by the usb reset detection ? enable the transceiver. in this state, the en_udphs bit in udphs_ctrl register must be enabled. 38.5.12.5 from default state to address state (address assigned) after a set address standard device request, the usb host peripheral enters the address state. warning : before the device enters address state, it must achieve the status in transaction of the control transfer, i.e., the udphs device sets its new address once the tx_complt flag in the udphs_eptctl[0] register has been received and cleared. to move to address state, the driver software sets the dev_addr field and the faddr_en flag in the udphs_ctrl register. 38.5.12.6 from address state to configured state (device configured) once a valid set configuration standard request has been received and acknowledged, the device enables endpoints corresponding to the current configuration. this is done by setting the bk_number, ept_type, ept_dir and ept_size fields in the udphs_eptcfgx registers and enabling them by setting the ept_enabl flag in the udphs_eptctlenbx registers, and, optionally, enabling corresponding interrupts in the udphs_ien register.
851 6438fCatarmC21-jun-10 at91sam9g45 38.5.12.7 entering suspend state (bus activity) when a suspend (no bus activity on the usb bus ) is detected, the det_suspd signal in the udphs_sta register is set. this triggers an in terrupt if the corresponding bit is set in the udphs_ien register. this flag is cleared by wr iting to the udphs_clrint register. then the device enters suspend mode. in this state bus powered devices must drain less than 500 a from the 5v vbus. as an exam- ple, the microcontroller switches to slow clock, disables the pl l and main osc illator, and goes into idle mode. it may also switch off other devices on the board. the udphs device peripheral clocks can be s witched off. resume ev ent is asynchronously detected. 38.5.12.8 receiving a host resume in suspend mode, a resume event on the usb bus line is detected asynchronously, transceiver and clocks disabled (however the pull-up should not be removed). once the resume is detected on the bus, the signal wake_up in the udphs_intsta is set. it may generate an interrupt if the corresponding bit in the udphs_ien register is set. this inter- rupt may be used to wake-up th e core, enable pll an d main oscillators and configure clocks. 38.5.12.9 sending an external resume in suspend state it is possible to wake-up the host by sending an external resume. the device waits at least 5 ms after being entered in suspend state before sending an external resume. the device must force a k state from 1 to 15 ms to resume the host.
852 6438fCatarmC21-jun-10 at91sam9g45 38.5.13 test mode a device must support the test_mode feature when in the default, address or configured high speed device states. test_mode can be: ?test_j ?test_k ? test_packet ? test_seo_nak (see section 38.6.7 udphs test register on page 864 for definitions of each test mode.) const char test_packet_buffer[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // jkjkjkjk * 9 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, // jjkkjjkk * 8 0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee, // jjkkjjkk * 8 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // jjjjjjjkkkkkkk * 8 0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd, // jjjjjjjk * 8 0xfc,0x7e,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0x7e // {jkkkkkkk * 10}, jk };
853 6438fCatarmC21-jun-10 at91sam9g45 38.6 usb high speed device po rt (udphs) user interface notes: 1. the reset value for udphs_eptctl0 is 0x0000_0001. 2. the addresses for the udphs endpoint regi sters shown here are for udphs endpoint0. the structure of this group of reg- isters is repeated successively for each endpoint according to the consecution of endpoint registers located between 0x120 and 0x1dc . 3. the addresses for the udphs dma registers shown here are for udphs dma channel1. (there is no channel0) the structure of this group of registers is repeated successively for each dma channel according to the consecution of dma reg- isters located between 0x320 and 0x370. table 38-5. register mapping offset register name access reset 0x00 udphs control register udphs_ctrl read-write 0x0000_0200 0x04 udphs frame number register udphs_fnum read 0x0000_0000 0x08 - 0x0c reserved C C C 0x10 udphs interrupt enable register udphs_ien read-write 0x0000_0010 0x14 udphs interrupt status register udphs_intsta read 0x0000_0000 0x18 udphs clear interrupt register udphs_clrint write C 0x1c udphs endpoints reset register udphs_eptrst write C 0x20 - 0xcc reserved C C C 0xe0 udphs test register udphs_tst read-write 0x0000_0000 0xe4 - 0xe8 reserved C C C 0xf0 udphs name1 register udphs_ipname1 read 0x4855_5342 0xf4 udphs name2 register udphs_ipname2 read 0x3244_4556 0xf8 udphs features register udphs_ipfeatures read 0x100 + endpoint * 0x20 + 0x00 udphs endpoint conf iguration register udphs_eptcfg read-write 0x0000_0000 0x100 + endpoint * 0x20 + 0x04 udphs endpoint c ontrol enable register udphs_eptctlenb write C 0x100 + endpoint * 0x20 + 0x08 udphs endpoint c ontrol disable register udphs_eptctldis write C 0x100 + endpoint * 0x20 + 0x0c udphs endpoint control register udphs_eptctl read 0x0000_0000 (1) 0x100 + endpoint * 0x20 + 0x10 reserved (for endpoint) C C C 0x100 + endpoint * 0x20 + 0x14 udphs endpoint set status register udphs_eptsetsta write C 0x100 + endpoint * 0x20 + 0x18 udphs endpoint clear status register udphs_eptclrsta write C 0x100 + endpoint * 0x20 + 0x1c udphs endpoint status register udphs_eptsta read 0x0000_0040 0x120 - 0x1dc udphs endpoint1 to 6 (2) registers 0x1e0 - 0x300 reserved 0x300 - 0x30c reserved C C C 0x310 + channel * 0x10 + 0x00 udphs dma next descript or address register udphs_d manxtdsc read-write 0x0000_0000 0x310 + channel * 0x10 + 0x04 udphs dma channel address register udphs_dmaaddress read-write 0x0000_0000 0x310 + channel * 0x10 + 0x08 udphs dma channel c ontrol register udphs_dmacontrol read-write 0x0000_0000 0x310 + channel * 0x10 + 0x0c udphs dma channel st atus register udphs_dmastatus read-write 0x0000_0000 0x320 - 0x370 dma channel2 to 5 (3) registers
854 6438fCatarmC21-jun-10 at91sam9g45 38.6.1 udphs control register name: udphs_ctrl address: 0xfff78000 access type: read-write ? dev_addr: udphs address read: this field contains the default address (0) after power-up or udphs bus reset. write: this field is written with the value set by a set_address request received by the device firmware. ? faddr_en: function address enable read: 0 = device is not in address state. 1 = device is in address state. write: 0 = only the default function address is used (0). 1 = this bit is set by the device firm ware after a successful status phase of a set_address transaction. when set, the only address accepted by the udphs cont roller is the one stored in the udphs a ddress field. it will not be cleared after- wards by the device firmware. it is cleared by hardware on hardware reset, or when udphs bus reset is received (see above). ? en_udphs: udphs enable read: 0 = udphs is disabled. 1 = udphs is enabled. write: 0 = disable and reset the udphs controller. switch the host to utmi. 1 = enables the udphs controller. switch the host to utmi. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCpulld_disrewakeupdetachen_udphs 76543210 faddr_en dev_addr
855 6438fCatarmC21-jun-10 at91sam9g45 ? detach: detach command read: 0 = udphs is attached. 1 = udphs is detached, utmi transceiver is suspended. write: 0 = pull up the dp line (attach command). 1 = simulate a detach on the udphs line and force the utmi transceiver into suspend state (suspend m = 0). (see pulld_dis description below.) ? rewakeup : send remote wake up read: 0 = remote wake up is disabled. 1 = remote wake up is enabled. write: 0 = no effect. 1 = force an external interrupt on the udphs controller for remote wake up purposes. an upstream resume is sent only after the udphs bus has been in suspend st ate for at least 5 ms. this bit is automatically cleared by hardware at the end of the upstream resume. ? pulld_dis: pull-down disable when set, there is no pull-down on dp & dm. (dm pull-down = dp pull-down = 0). note: if the detach bit is also set, device dp & dm are left in high impedance state. (see detach description above.) detach pulld_dis dp dm condition 0 0 pull up pull down not recommended 0 1 pull up high impedance state vbus present 1 0 pull down pull down no vbus 11 high impedance state high impedance state vbus present & software disconnect
856 6438fCatarmC21-jun-10 at91sam9g45 38.6.2 udphs frame number register name: udphs_fnum address: 0xfff78004 access type: read ? micro_frame_num: microframe number number of the received microframe (0 to 7) in one frame.this field is reset at the beginning of each new frame (1 ms). one microframe is received each 125 microseconds (1 ms/8). ? frame_number: frame number as defined in the packet field formats this field is provided in the last received sof packet (see int_sof in the udphs interrupt status register ). ? fnum_err: frame number crc error this bit is set by hardware when a corrupted frame number in start of frame packet (or micro sof) is received. this bit and the int_sof (or micro_sof) interrupt are updated at the same time. 31 30 29 28 27 26 25 24 fnum_errCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 C C frame_number 76543210 frame_number micro_frame_num
857 6438fCatarmC21-jun-10 at91sam9g45 38.6.3 udphs interrupt enable register name: udphs_ien address: 0xfff78010 access type: read-write ? det_suspd: suspend interrupt enable read: 0 = suspend interrupt is disabled. 1 = suspend interrupt is enabled. write: 0 = disable suspend interrupt. 1 = enable suspend interrupt. ? micro_sof: micro-sof interrupt enable read: 0 = micro-sof interrupt is disabled. 1 = micro-sof interrupt is enabled. write: 0 = disable micro-sof interrupt. 1 = enable micro-sof interrupt. ? int_sof: sof interrupt enable read: 0 = sof interrupt is disabled. 1 = sof interrupt is enabled. write: 0 = disable sof interrupt. 1 = enable sof interrupt. 31 30 29 28 27 26 25 24 C dma_6 dma_5 dma_4 dma_3 dma_2 dma_1 C 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 C ept_6 ept_5 ept_4 ept_3 ept_2 ept_1 ept_0 76543210 upstr_res endofrsm wake_up endreset int_sof micro_sof det_suspd C
858 6438fCatarmC21-jun-10 at91sam9g45 ? endreset: end of reset interrupt enable read: 0 = end of reset interrupt is disabled. 1 = end of reset interrupt is enabled. write: 0 = disable end of reset interrupt. 1 = enable end of reset interrupt. automatically enabled after usb reset. ? wake_up: wake up cpu interrupt enable read: 0 = wake up cpu interrupt is disabled. 1 = wake up cpu interrupt is enabled. write 0 = disable wake up cpu interrupt. 1 = enable wake up cpu interrupt. ? endofrsm: end of resume interrupt enable read: 0 = resume interrupt is disabled. 1 = resume interrupt is enabled. write: 0 = disable resume interrupt. 1 = enable resume interrupt. ? upstr_res: upstream resume interrupt enable read: 0 = upstream resume interrupt is disabled. 1 = upstream resume interrupt is enabled. write: 0 = disable upstream resume interrupt. 1 = enable upstream resume interrupt. ? ept_x: endpoint x interrupt enable read: 0 = the interrupts for this endpoint are disabled. 1 = the interrupts for this endpoint are enabled.
859 6438fCatarmC21-jun-10 at91sam9g45 write: 0 = disable the interrupts for this endpoint. 1 = enable the interrupts for this endpoint. ? dma_x: dma channel x interrupt enable read: 0 = the interrupts for this channel are disabled. 1 = the interrupts for this channel are enabled. write: 0 = disable the interrupts for this channel. 1 = enable the interrupts for this channel.
860 6438fCatarmC21-jun-10 at91sam9g45 38.6.4 udphs interrupt status register name: udphs_intsta address: 0xfff78014 access type: read-only ? speed: speed status 0 = reset by hardware when the hardware is in full speed mode. 1 = set by hardware when the hardware is in high speed mode ? det_suspd: suspend interrupt 0 = cleared by setting the det_suspd bit in udphs_clrint register 1 = set by hardware when a udphs suspend (idle bus for three frame periods, a j state for 3 ms) is detected. this triggers a udphs interrupt when the det_suspd bit is set in udphs_ien register. ? micro_sof: micro start of frame interrupt 0 = cleared by setting the micro_sof bit in udphs_clrint register. 1 = set by hardware when an udphs micro start of frame pi d (sof) has been detected (every 125 us) or synthesized by the macro. this triggers a udphs interrupt when the micro_sof bit is set in udphs_ien. in case of detected sof, the micro_frame_num field in udphs_fnum register is incremented and the frame_number field doesnt change. note: the micro start of frame interrupt (micro_sof), and the star t of frame interrupt (int_sof) are not generated at the same time. ? int_sof: start of frame interrupt 0 = cleared by setting the int_sof bit in udphs_clrint. 1 = set by hardware when an udphs start of frame pid (s of) has been detected (every 1 ms) or synthesized by the macro. this triggers a udphs interrupt when the int_sof bit is set in udphs_ien register. in case of detected sof, in high speed mode, the micro_frame_number field is cl eared in udphs_fnum register and the frame_number field is updated. ? endreset: end of reset interrupt 0 = cleared by setting the endreset bit in udphs_clrint. 1 = set by hardware when an end of reset has been detected by the udphs controller. this triggers a udphs interrupt when the endreset bit is set in udphs_ien. 31 30 29 28 27 26 25 24 C dma_6 dma_5 dma_4 dma_3 dma_2 dma_1 C 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 C ept_6 ept_5 ept_4 ept_3 ept_2 ept_1 ept_0 76543210 upstr_res endofrsm wake_up endreset int_sof micro_sof det_suspd speed
861 6438fCatarmC21-jun-10 at91sam9g45 ? wake_up: wake up cpu interrupt 0 = cleared by setting the wake_up bit in udphs_clrint. 1 = set by hardware when the udphs cont roller is in suspend state and is re-act ivated by a filtered non-idle signal from the udphs line (not by an upstream resume). this tr iggers a udphs interrupt wh en the wake_up bit is set in udphs_ien register. when receiving this interrupt, the user has to enable the device controller clock prior to operation. note: this interrupt is generated even if the device controller clock is disabled. ? endofrsm: end of resume interrupt 0 = cleared by setting the endofrsm bit in udphs_clrint. 1 = set by hardware when the udphs controller detects a good en d of resume signal initiated by the host. this triggers a udphs interrupt when the endofr sm bit is set in udphs_ien. ? upstr_res: upstream resume interrupt 0 = cleared by setting the upstr_res bit in udphs_clrint. 1 = set by hardware when the udphs controller is sending a resume signal called upstream resume. this triggers a udphs interrupt when the upstr_ res bit is set in udphs_ien. ? ept_x: endpoint x interrupt 0 = reset when the udphs_eptstax interrupt source is cleared. 1 = set by hardware when an interrupt is triggered by the ud phs_eptstax register and this endpoint interrupt is enabled by the ept_x bit in udphs_ien. ? dma_x: dma channel x interrupt 0 = reset when the udphs_dmastatusx interrupt source is cleared. 1 = set by hardware when an interrupt is triggered by the dma channelx and this endpoint interrupt is enabled by the dma_x bit in udphs_ien.
862 6438fCatarmC21-jun-10 at91sam9g45 38.6.5 udphs clear interrupt register name: udphs_clrint address: 0xfff78018 access type: write only ? det_suspd: suspend interrupt clear 0 = no effect. 1 = clear the det_suspd bit in udphs_intsta. ? micro_sof: micro start of frame interrupt clear 0 = no effect. 1 = clear the micro_sof bit in udphs_intsta. ? int_sof: start of frame interrupt clear 0 = no effect. 1 = clear the int_sof bit in udphs_intsta. ? endreset: end of re set interrupt clear 0 = no effect. 1 = clear the endreset bit in udphs_intsta. ? wake_up: wake up cpu interrupt clear 0 = no effect. 1 = clear the wake_up bit in udphs_intsta. ? endofrsm: end of resume interrupt clear 0 = no effect. 1 = clear the endofrsm bit in udphs_intsta. ? upstr_res: upstream resume interrupt clear 0 = no effect. 1 = clear the upstr_res bit in udphs_intsta. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 upstr_res endofrsm wake_up endreset int_sof micro_sof det_suspd C
863 6438fCatarmC21-jun-10 at91sam9g45 38.6.6 udphs endpoints reset register name: udphs_eptrst address: 0xfff7801c access type: write only ? ept_x: endpoint x reset 0 = no effect. 1 = reset the endpointx state. setting this bit clears the endpoint status udphs_ eptstax register, except fo r the togglesq_sta field. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C ept_6 ept_5 ept_4 ept_3 ept_2 ept_1 ept_0
864 6438fCatarmC21-jun-10 at91sam9g45 38.6.7 udphs test register name: udphs_tst address: 0xfff780e0 access type: read-write ? speed_cfg: speed configuration read-write: speed configuration: ? tst_j: test j mode read and write: 0 = no effect. 1 = set to send the j state on the udphs line. this enables the testing of the high output drive level on the d+ line. ? tst_k: test k mode read and write: 0 = no effect. 1 = set to send the k state on the udphs line. this enables the testing of the high output drive level on the d- line. ? tst_pkt: test packet mode read and write: 0 = no effect. 1 = set to repetitively transmit the packet stored in the current bank. this enables the testing of rise and fall times, eye pa t- terns, jitter, and any other dynamic waveform specifications. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C opmode2 tst_pkt tst_k tst_j speed_cfg 00 normal mode: the macro is in full speed mode, ready to make a high speed identification, if the host supports it and then to automatically switch to high speed mode 01 reserved 10 force high speed: set this value to force the hardware to work in high speed mode. only for debug or test purpose. 11 force full speed: set this value to force the hardware to work only in full speed mode. in this configuration, the macro will not respond to a high speed reset handshake
865 6438fCatarmC21-jun-10 at91sam9g45 ? opmode2: opmode2 read and write: 0 = no effect. 1 = set to force the opmode signal (utmi interface) to 10, to disable the bit-stuffing and the nrzi encoding. note: for the test mode, test_se0_nak (see universal serial bus specification, revision 2.0: 7.1.20, test mode sup- port). force the device in high speed m ode, and configure a bulk-ty pe endpoint. do not fill this endpoint for sending nak to the host. upon command, a ports transceiver must enter the high speed receive mode and remain in that mode until the exit action is taken. this enables the testing of output impedance, low level output voltage and loading characteristics. in addition, while in this mode, upstream facing ports (and only upstream facing ports) must respond to any in token packet with a nak handshake (only if the packet crc is dete rmined to be correct) within the norm al allowed device response time. this enables testing of the device squelch level circuitry and, additi onally, provides a general purpose stimulus/response test for basic functional testing.
866 6438fCatarmC21-jun-10 at91sam9g45 38.6.8 udphs name1 register name: udphs_ipname1 address: 0xfff780f0 access type: read-only ? ip_name1 ascii string husb 31 30 29 28 27 26 25 24 ip_name1 23 22 21 20 19 18 17 16 ip_name1 15 14 13 12 11 10 9 8 ip_name1 76543210 ip_name1
867 6438fCatarmC21-jun-10 at91sam9g45 38.6.9 udphs name2 register name: udphs_ipname2 address: 0xfff780f4 access type: read-only ? ip_name2 ascii string 2dev 31 30 29 28 27 26 25 24 ip_name2 23 22 21 20 19 18 17 16 ip_name2 15 14 13 12 11 10 9 8 ip_name2 76543210 ip_name2
868 6438fCatarmC21-jun-10 at91sam9g45 38.6.10 udphs features register name: udphs_ipfeatures address: 0xfff780f8 access type: read-only ? ept_nbr_max: max number of endpoints give the max number of endpoints. 0 = if 16 endpoints are hardware implemented. 1 = if 1 endpoint is hardware implemented. 2 = if 2 endpoints are hardware implemented. ... 15 = if 15 endpoints are hardware implemented. ? dma_channel_nbr: number of dma channels give the number of dma channels. 1 = if 1 dma channel is hardware implemented. 2 = if 2 dma channels are hardware implemented. ... 7 = if 7 dma channels are hardware implemented. ? dma_b_siz: dma buffer size 0 = if the dma buffer size is 16 bits. 1 = if the dma buffer size is 24 bits. ? dma_fifo_word_depth: dma fifo depth in words 0 = if fifo is 16 words deep. 1 = if fifo is 1 word deep. 2 = if fifo is 2 words deep. ... 15 = if fifo is 15 words deep. 31 30 29 28 27 26 25 24 iso_ept_15 iso_ept_14 iso_ept_13 iso_ept_ 12 iso_ept_11 iso_ept_1 0 iso_ept_9 iso_ept_8 23 22 21 20 19 18 17 16 iso_ept_7 iso_ept_6 iso_ept_5 iso_ept_4 is o_ept_3 iso_ept_2 iso_ept_1 datab16_8 15 14 13 12 11 10 9 8 bw_dpram fifo_max_size dma_fifo_word_depth 76543210 dma_b_siz dma_channel_nbr ept_nbr_max
869 6438fCatarmC21-jun-10 at91sam9g45 ? fifo_max_size: dpram size 0 = if dpram is 128 bytes deep. 1 = if dpram is 256 bytes deep. 2 = if dpram is 512 bytes deep. 3 = if dpram is 1024 bytes deep. 4 = if dpram is 2048 bytes deep. 5 = if dpram is 4096 bytes deep. 6 = if dpram is 8192 bytes deep. 7 = if dpram is 16384 bytes deep. ? bw_dpram: dpram by te write capability 0 = if dpram write data shadow logic is implemented. 1 = if dpram is byte write capable. ? datab16_8: utmi databus16_8 0 = if the utmi uses an 8-bit parallel data interface (60 mhz, unidirectional). 1 = if the utmi uses a 16-bit parallel data interface (30 mhz, bidirectional). ? iso_ept_x: endpointx high bandwidth isochronous capability 0 = if the endpoint does not have isochronous high bandwidth capability. 1 = if the endpoint has isochronous high bandwidth capability.
870 6438fCatarmC21-jun-10 at91sam9g45 38.6.11 udphs endpoint configuration register name: udphs_eptcfgx [x=0..6] addresses: 0xfff78100 [0], 0xfff78120 [1], 0xfff78140 [2], 0xfff78160 [3], 0xfff78180 [4], 0xfff781a0 [5], 0xfff781c0 [6] access type: read-write ? ept_size: endpoint size read and write: set this field according to the endpoint size in bytes (see section 38.5.5 endpoint configuration ). endpoint size note: 1. 1024 bytes is only for isochronous endpoint. ? ept_dir: endpoint direction read and write: 0 = clear this bit to configure out direction for bulk, interrupt and isochronous endpoints. 1 = set this bit to configure in direction for bulk, interrupt and isochronous endpoints. for control endpoints this bit has no effect and should be left at zero. ? ept_type: endpoint type read and write: set this field according to the endpoint type (see section 38.5.5 endpoint configuration ). (endpoint 0 should always be configured as control) 31 30 29 28 27 26 25 24 ept_mapdCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCC nb_trans 76543210 bk_number ept_type ept_dir ept_size 000 8 bytes 001 16 bytes 010 32 bytes 011 64 bytes 100 128 bytes 101 256 bytes 110 512 bytes 111 1024 bytes (1)
871 6438fCatarmC21-jun-10 at91sam9g45 :endpoint type ? bk_number: number of banks read and write: set this field according to the endpoints number of banks (see section 38.5.5 endpoint configuration ). number of banks ? nb_trans: number of tr ansaction per microframe read and write: the number of transactions per microframe is set by software. note: meaningful for high bandwidth isochronous endpoint only. ? ept_mapd: endpoint mapped read-only: 0 = the user should reprogram the register with correct values. 1 = set by hardware when the endpoint size (ept_size) an d the number of banks (bk_number) are correct regarding: C the fifo max capacity (fifo_max_ size in udphs_ipfeatures register) C the number of endpoints/banks already allocated C the number of allowed banks for this endpoint 00 control endpoint 01 isochronous endpoint 10 bulk endpoint 11 interrupt endpoint 00 zero bank, the endpoint is not mapped in memory 01 one bank (bank 0) 10 double bank (ping-pong: bank 0/bank 1) 11 triple bank (bank 0/bank 1/bank 2)
872 6438fCatarmC21-jun-10 at91sam9g45 38.6.12 udphs endpoint control enable register name: udphs_eptctlenbx [x=0..6] addresses: 0xfff78104 [0], 0xfff78124 [1], 0xfff78144 [2], 0xfff78164 [3], 0xfff78184 [4], 0xfff781a4 [5], 0xfff781c4 [6] access type: write-only for additional information, see udphs endpoint contro l register on page 876 . ? ept_enabl: endpoint enable 0 = no effect. 1 = enable endpoint according to the device configuration. ? auto_valid: packet auto-valid enable 0 = no effect. 1 = enable this bit to automatically validate the current packet and switch to the next bank for both in and out transfers. ? intdis_dma: interrupts disable dma 0 = no effect. 1 = if set, when an enabled endpoint-originated interrupt is triggered, the dma request is disabled. ? nyet_dis: nyet disable (only fo r high speed bulk out endpoints) 0 = no effect. 1 = forces an ack response to the next high spee d bulk out transfer instead of a nyet response. ? datax_rx: datax interrupt enable (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = enable datax interrupt. ? mdata_rx: mdata interrupt enable (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = enable mdata interrupt. 31 30 29 28 27 26 25 24 shrt_pcktCCCCCCC 23 22 21 20 19 18 17 16 CCCCCbusy_bankCC 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_criso/ err_nbtra rx_setup/ err_fl_iso tx_pk_rdy/ err_trans tx_complt rx_bk_rdy err_ovflw 76543210 mdata_rx datax_rx C nyet_dis intdis_dma C auto_valid ept_enabl
873 6438fCatarmC21-jun-10 at91sam9g45 ? err_ovflw: overflow error interrupt enable 0 = no effect. 1 = enable overflow error interrupt. ? rx_bk_rdy: received out data interrupt enable 0 = no effect. 1 = enable received out data interrupt. ? tx_complt: transmitted in data complete interrupt enable 0 = no effect. 1 = enable transmitted in data complete interrupt. ? tx_pk_rdy/err_trans: tx packet read y/transaction error interrupt enable 0 = no effect. 1 = enable tx packet ready/transaction error interrupt. ? rx_setup/err_fl_iso: received set up/error flow interrupt enable 0 = no effect. 1 = enable rx_setup/error flow iso interrupt. ? stall_snt/err_criso/err_nbtra: stal l sent /iso crc error/number of transaction error interrupt enable 0 = no effect. 1 = enable stall sent/error crc iso/erro r number of tran saction interrupt. ? nak_in/err_flush: nakin/bank flush error interrupt enable 0 = no effect. 1 = enable nakin/bank flush error interrupt. ? nak_out: nakout interrupt enable 0 = no effect. 1 = enable nakout interrupt. ? busy_bank: busy bank interrupt enable 0 = no effect. 1 = enable busy bank interrupt. ? shrt_pckt: short packet send/short packet interrupt enable for out endpoints: 0 = no effect. 1 = enable short packet interrupt. for in endpoints: guarantees short packet at end of dma transfer if the udphs_dmacontrolx register end_b_en and udphs_eptctlx register autovalid bits are also set.
874 6438fCatarmC21-jun-10 at91sam9g45 38.6.13 udphs endpoint control disable register name: udphs_eptctldisx [x=0..6] addresses: 0xfff78108 [0], 0xfff78128 [1], 0xfff78148 [2], 0xfff78168 [3], 0xfff78188 [4], 0xfff781a8 [5], 0xfff781c8 [6] access type: write-only for additional information, see udphs endpoint contro l register on page 876 . ? ept_disabl: endpoint disable 0 = no effect. 1 = disable endpoint. ? auto_valid: packet auto-valid disable 0 = no effect. 1 = disable this bit to not automatically validate the current packet. ? intdis_dma: interrupts disable dma 0 = no effect. 1 = disable the interrupts disable dma. ? nyet_dis: nyet enable (only for high speed bulk out endpoints) 0 = no effect. 1 = let the hardware handle the handshake response for the high speed bulk out transfer. ? datax_rx: datax interrupt disable (only fo r high bandwidth isochronous out endpoints) 0 = no effect. 1 = disable datax interrupt. ? mdata_rx: mdata interrupt disable (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = disable mdata interrupt. 31 30 29 28 27 26 25 24 shrt_pcktCCCCCCC 23 22 21 20 19 18 17 16 CCCCCbusy_bankCC 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_criso/ err_nbtra rx_setup/ err_fl_iso tx_pk_rdy/ err_trans tx_complt rx_bk_rdy err_ovflw 76543210 mdata_rx datax_rx C nyet_dis intdis_dma C auto_valid ept_disabl
875 6438fCatarmC21-jun-10 at91sam9g45 ? err_ovflw: overflow error interrupt disable 0 = no effect. 1 = disable overflow error interrupt. ? rx_bk_rdy: received out data interrupt disable 0 = no effect. 1 = disable received out data interrupt. ? tx_complt: transmitted in data complete interrupt disable 0 = no effect. 1 = disable transmitted in data complete interrupt. ? tx_pk_rdy/err_trans: tx packet read y/transaction error interrupt disable 0 = no effect. 1 = disable tx packet ready/transaction error interrupt. ? rx_setup/err_fl_iso: received setup /error flow interrupt disable 0 = no effect. 1 = disable rx_setup/error flow iso interrupt. ? stall_snt/err_criso/err_nbtra: stall sent/iso crc er ror/number of transacti on error interrupt disable 0 = no effect. 1 = disable stall sent/error crc iso/error number of transaction interrupt. ? nak_in/err_flush: nakin/bank flush error interrupt disable 0 = no effect. 1 = disable nakin/ bank flush error interrupt. ? nak_out: nakout interrupt disable 0 = no effect. 1 = disable nakout interrupt. ? busy_bank: busy bank interrupt disable 0 = no effect. 1 = disable busy bank interrupt. ? shrt_pckt: short packet interrupt disable for out endpoints: 0 = no effect. 1 = disable short packet interrupt. for in endpoints: never automatically add a zero length packet at end of dma transfer.
876 6438fCatarmC21-jun-10 at91sam9g45 38.6.14 udphs endpoint control register name: udphs_eptctlx [x=0..6] addresses: 0xfff7810c [0], 0xfff7812c [1], 0xfff7814c [2], 0xfff7816c [3], 0xfff7818c [4], 0xfff781ac [5], 0xfff781cc [6] access type: read-only ? ept_enabl: endpoint enable 0 = if cleared, the endpoint is disabled according to the devi ce configuration. endpoint 0 should always be enabled after a hardware or udphs bus reset and participate in the device configuration. 1 = if set, the endpoint is enabled according to the device configuration. ? auto_valid: packet auto-valid enabled (not for control endpoints) set this bit to automatically validate the current packet and switch to the next bank for both in and out endpoints. for in transfer: if this bit is set, then the udphs_eptst ax register tx_pk_rdy bit is set automat ically when the current bank is full and at the end of dma buffer if the udphs_dmacontrolx register end_b_en bit is set. the user may still set the udphs_eptstax register tx_pk_ rdy bit if the current bank is not full, unless the user wants to send a zero length packet by software. for out transfer: if this bit is set, then the udphs_eptstax register rx_ bk_rdy bit is automatically reset for the current bank when the last packet byte has been read from the bank fifo or at the end of dma buffer if the udphs_dmacontrolx register end_b_en bit is set. for example, to truncate a padded data packet when the actual data transfer size is reached. the user may still clear the udphs_eptstax register rx _bk_rdy bit, for example, after completing a dma buffer by software if udphs_dmacontrolx register end_b_en bi t was disabled or in order to cancel the read of the remaining data bank(s). ? intdis_dma: interrupt disables dma if set, when an enabled endpoint-originated interrupt is triggered, the dma request is disabled regardless of the udphs_ien register ept_x bit for this endpoint. then, the firmw are will have to clear or disable the interrupt source or clear this bit if transfer completion is needed. 31 30 29 28 27 26 25 24 shrt_pcktCCCCCCC 23 22 21 20 19 18 17 16 CCCCCbusy_bankCC 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_criso/ err_nbtra rx_setup/ err_fl_iso tx_pk_rdy/ err_trans tx_complt rx_bk_rdy err_ovflw 76543210 mdata_rx datax_rx C nyet_dis intdis_dma C auto_valid ept_enabl
877 6438fCatarmC21-jun-10 at91sam9g45 if the exception raised is associated with the new system bank packet, then the previous dma packet transfer is normally completed, but the new dma packet transfer is not started (not requested). if the exception raised is not associated to a new system bank packet (nak_in, nak_out, err_fl_iso...), then the request cancellation may happen at any time and may immediately stop the current dma transfer. this may be used, for example, to identify or prevent an erroneous packet to be transferred into a buffer or to complete a dma buffer by software after reception of a short packet, or to perform buffer truncation on err_fl_iso interrupt for adaptive rate. ? nyet_dis: nyet disable (only for high speed bulk out endpoints) 0 = if clear, this bit lets the hardware handle the handshake response for the high speed bulk out transfer. 1 = if set, this bit forces an ack response to the next high speed bulk out transfer instead of a nyet response. note: according to the universal serial bus specification, rev 2.0 (8.5.1.1 nak responses to out/ data during ping protocol), a nak response to an hs bulk out transfer is expected to be an unusual occurrence. ? datax_rx: datax interrupt enabled (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = send an interrupt when a data2, da ta1 or data0 packet has been received meaning the whole microframe data payload has been received. ? mdata_rx: mdata interrupt enabled (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = send an interrupt when an mdata packet has been received and so at least one packet of the microframe data pay- load has been received. ? err_ovflw: overflow error interrupt enabled 0 = overflow error interrupt is masked. 1 = overflow error interrupt is enabled. ? rx_bk_rdy: received out data interrupt enabled 0 = received out data interrupt is masked. 1 = received out data interrupt is enabled. ? tx_complt: transmitted in data complete interrupt enabled 0 = transmitted in data co mplete interrupt is masked. 1 = transmitted in data comp lete interrupt is enabled. ? tx_pk_rdy/err_trans: tx packet read y/transaction error interrupt enabled 0 = tx packet ready/transaction error interrupt is masked. 1 = tx packet ready/transaction error interrupt is enabled. caution: interrupt source is active as long as the corres ponding udphs_eptstax regist er tx_pk_rdy flag remains low. if there are no more banks available for transmitting after the software has set udphs_eptstax/tx_pk_rdy for the last transmit packet, then the interrupt source remains inactive until the first bank becomes free again to transmit at udphs_eptstax/tx_pk_ rdy hardware clear.
878 6438fCatarmC21-jun-10 at91sam9g45 ? rx_setup/err_fl_iso: received setup /error flow interrupt enabled 0 = received setup/error flow interrupt is masked. 1 = received setup/error flow interrupt is enabled. ? stall_snt/err_criso/err_nbtra: stall sent/iso crc er ror/number of transaction error interrupt enabled 0 = stall sent/iso crc error/number of transaction error interrupt is masked. 1 = stall sent /iso crc error/number of transaction error interrupt is enabled. ? nak_in/err_flush: nakin/bank flush error interrupt enabled 0 = nakin interrupt is masked. 1 = nakin/bank flush error interrupt is enabled. ? nak_out: nakout interrupt enabled 0 = nakout interrupt is masked. 1 = nakout interrupt is enabled. ? busy_bank: busy bank interrupt enabled 0 = busy_bank interrupt is masked. 1 = busy_bank interrupt is enabled. for out endpoints : an interrupt is sent when all banks are busy. for in endpoints: an interrupt is sent when all banks are free. ? shrt_pckt: short packet interrupt enabled for out endpoints : send an interrupt when a short packet has been received. 0 = short packet interrupt is masked. 1 = short packet interrupt is enabled. for in endpoints : a short packet transmission is guaranteed upon end of the dma transfer, thus signaling a bulk or interrupt end of transfer or an en d of isochronous (micro-)frame data , but only if the udphs_dmacontrolx register end_b_en and udphs_eptctlx re gister auto_valid bits are also set.
879 6438fCatarmC21-jun-10 at91sam9g45 38.6.15 udphs endpoint set status register name: udphs_eptsetstax [x=0..6] addresses: 0xfff78114 [0], 0xfff78134 [1], 0xfff78154 [2], 0xfff78174 [3], 0xfff78194 [4], 0xfff781b4 [5], 0xfff781d4 [6] access type: write-only ? frcestall: stall handshake request set 0 = no effect. 1 = set this bit to request a stall answer to the host for the next handshake refer to chapters 8.4.5 (handshake packets) and 9.4.5 (get status) of the universal serial bus sp ecification, rev 2.0 for more information on the stall handshake. ? kill_bank: kill bank set (for in endpoint) 0 = no effect. 1 = kill the last written bank. ? tx_pk_rdy: tx packet ready set 0 = no effect. 1 = set this bit after a packet has been written into the endpoint fifo for in data transfers C this flag is used to generate a data in transaction (device to host). C device firmware checks that it can write a data payload in the fifo, checking that tx_pk_rdy is cleared. C transfer to the fifo is done by writing in the buffer address register. C once the data payload has been transferred to the fifo, the firmware notifies the udphs device setting tx_pk_rdy to one. C udphs bus transactions can start. C txcomp is set once the data payload has been received by the host. C data should be written into the endpoint fifo only after this bit has been cleared. C set this bit without writing data to the endpoint fifo to send a zero length packet. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCtx_pk_rdyCki ll_bank C 76543210 CCfrcestallCCCCC
880 6438fCatarmC21-jun-10 at91sam9g45 38.6.16 udphs endpoint clear status register name: udphs_eptclrstax [x=0..6] addresses: 0xfff78118 [0], 0xfff78138 [1], 0xfff78158 [2], 0xfff78178 [3], 0xfff78198 [4] 0xfff781b8 [5], 0xfff781d8 [6] access type: write-only ? frcestall: stall handshake request clear 0 = no effect. 1 = clear the stall request. the next packets from host will not be stalled. ? togglesq: data toggle clear 0 = no effect. 1 = clear the pid data of the current bank for out endpoints, the next received packet should be a data0. for in endpoints, the next pa cket will be sent with a data0 pid. ? rx_bk_rdy: receive d out data clear 0 = no effect. 1 = clear the rx_bk_rdy flag of udphs_eptstax. ? tx_complt: transmitted in data complete clear 0 = no effect. 1 = clear the tx_complt flag of udphs_eptstax. ? rx_setup/err_fl_iso: received setup/error flow clear 0 = no effect. 1 = clear the rx_setup/err_fl_iso flags of udphs_eptstax. ? stall_snt/err_nbtra: stall sent/number of transaction error clear 0 = no effect. 1 = clear the stall_snt/err_nbtra flags of udphs_eptstax. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_nbtra rx_setup/ err_fl_iso C tx_complt rx_bk_rdy C 76543210 CtogglesqfrcestallCCCCC
881 6438fCatarmC21-jun-10 at91sam9g45 ? nak_in/err_flush: nakin/bank flush error clear 0 = no effect. 1 = clear the nak_in/err_flus h flags of udphs_eptstax. ? nak_out: nakout clear 0 = no effect. 1 = clear the nak_out flag of udphs_eptstax.
882 6438fCatarmC21-jun-10 at91sam9g45 38.6.17 udphs endpoint status register name: udphs_eptstax [x=0..6] addresses: 0xfff7811c [0], 0xfff7813c [1], 0xfff 7815c [2], 0xfff7817c [3], 0xfff7819c [4], 0xfff781bc [5], 0xfff781dc [6] access type: read-only ? frcestall: stall handshake request 0 = no effect. 1= if set a stall answer will be done to the host for the next handshake. this bit is reset by hardware upon received setup. ? togglesq_sta: toggle sequencing toggle sequencing: C in endpoint: it indicates the pid data toggle that will be used for the next packe t sent. this is not relative to the current bank. C control and out endpoint: these bits are set by hardware to indicate the pid data of the current bank: note 1: in out transfer, the toggle information is meaningful only when the current bank is busy (received out data = 1). note 2: these bits are updated for out transfer: C a new data has been written into the current bank. C the user has just cleared the received out data bit to switch to the next bank. note 3: for high bandwidth isochronous out endpoint, it is recommended to check the udphs_eptstax/err_trans bit to know if the toggle sequencing is correct or not. 31 30 29 28 27 26 25 24 shrt_pckt byte_count 23 22 21 20 19 18 17 16 byte_count busy_bank_sta current_bank/ control_dir 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_criso/ err_nbtra rx_setup/ err_fl_iso tx_pk_rdy/ err_trans tx_complt rx_bk_rdy/ kill_bank err_ovflw 76543210 togglesq_stafrcestallCCCCC 00 data0 01 data1 10 data2 (only for high bandwidth isochronous endpoint) 11 mdata (only for high bandwidth isochronous endpoint)
883 6438fCatarmC21-jun-10 at91sam9g45 note 4: this field is reset to data1 by the udphs_eptclrs tax register togglesq bit, and by udphs_eptctldisx (disable endpoint). ? err_ovflw: overflow error this bit is set by hardware when a new too-long packet is received. example: if the user programs an endpoint 64 bytes wide and th e host sends 128 bytes in an out transfer, then the over- flow error bit is set. this bit is updated at the same time as the byte_count field. this bit is reset by udphs_eptrst register ept_x (reset endpoint) and by udphs_eptctldisx (disable endpoint). ? rx_bk_rdy/kill_bank: rece ived out data/kill bank C received out data : (for out endpoint or control endpoint) this bit is set by hardware after a new packet has been stored in the endpoint fifo. this bit is cleared by the device firmware af ter reading the out data from the endpoint. for multi-bank endpoints, this bit may remain active even when cleared by the device firmware, this if an other packet has been received meanwhile. hardware assertion of this bit may generate an interrupt if enabled by the udphs_eptctlx register rx_bk_rdy bit. this bit is reset by udphs_eptrst register ept_x (reset endpoint) and by udphs_eptctldisx (disable endpoint). C kill bank : (for in endpoint) C the bank is really cleared or the bank is sent, busy_bank_sta is decremented. C the bank is not cleared but sent on the in transfer, tx_complt C the bank is not cleared because it was empty. the user sh ould wait that this bit is cleared before trying to clear another packet. note: kill a packet may be refused if at the same time, an in token is coming and the curre nt packet is sent on the udphs line. in this case, the tx_complt bit is set. take notice however, that if at least two banks are ready to be sent, there is no problem to kill a packet even if an in token is coming. in fa ct, in that case, the current bank is sent (in transfe r) and the last bank is killed. ? tx_complt: transmitted in data complete this bit is set by hardware after an in packet has been transmitted for isochronous endpoints and after it has been accepted (acked) by the host for control, bulk and interrupt endpoints. this bit is reset by udphs_eptrst register ept_x (reset endpoint), and by udphs_eptctldisx (disable endpoint). ? tx_pk_rdy/err_trans: tx packet ready/transaction error C tx packet ready : this bit is cleared by hardware, as soon as the packet has been sent for isochronous endpoints, or after the host has acknowledged the packet for control, bulk and interrupt endpoints. for multi-bank endpoints, this bit may remain clear even afte r software is set if another bank is available to transmit. hardware clear of this bit may generate an interrupt if enabled by the udphs_eptctlx register tx_pk_rdy bit. this bit is reset by udphs_eptrst register ept_x (reset endpoint), and by udphs_eptctldisx (disable endpoint). C transaction error : (for high bandwidth isochronous out endpoints) (read-only) this bit is set by hardware when a transa ction error occurs inside one microframe.
884 6438fCatarmC21-jun-10 at91sam9g45 if one toggle sequencing problem occurs amo ng the n-transactions (n = 1, 2 or 3) in side a microframe, then this bit is still set as long as the current bank contains one bad n-transaction. (see current_bank/control_dir: current bank/control direction on page 885 ) as soon as the current bank is relative to a new good n-transactions, then this bit is reset. note1 : a transaction error occurs when the toggle sequencing does not respect the universal serial bus specification, rev 2.0 (5.9.2 high bandwidth isochronous endpoints) (bad pid, missing data....) note2 : when a transaction error occurs, the user may empty all the bad transactions by clearing the received out data flag (rx_bk_rdy). if this bit is reset, then the user should consider that a new n-transaction is coming. this bit is reset by udphs_eptrst register ept_x (reset endpoint), and by udphs_eptctldisx (disable endpoint). ? rx_setup/err_fl_iso: received setup/error flow C received setup : (for control endpoint only) this bit is set by hardware when a valid setup packet has been received from the host. it is cleared by the device firmware after reading the setup data from the endpoint fifo. this bit is reset by udphs_eptrst register ept_x (reset endpoint), and by udphs_eptctldisx (disable endpoint). C error flow : (for isochronous endpoint only) this bit is set by hardware w hen a transaction error occurs. C isochronous in transaction is missed, the micr o has no time to fill t he endpoint (underflow). C isochronous out data is dropped because the bank is busy (overflow). this bit is reset by udphs_eptrst register ept_x (reset endpoint) and by udphs_eptctldisx (disable endpoint). ? stall_snt/err_criso/err_nbtra: stall sent/c rc iso error/number of transaction error C stall_snt : (for control, bulk and interrupt endpoints) this bit is set by hardware after a stall handshake ha s been sent as requested by the udphs_eptstax register frcestall bit. this bit is reset by udphs_eptrst register ept_x (reset endpoint) and by udphs_eptctldisx (disable endpoint). C err_criso : (for isochronous out endpoints) (read-only) this bit is set by hardware if the last received data is corrupted (crc error on data). this bit is updated by hardware when new data is received (received out data bit). C err_nbtra : (for high bandwidth isochronous in endpoints) this bit is set at the end of a microframe in which at l east one data bank has been transmitted, if less than the number of transactions per micro-frame banks (udphs_eptcfgx regist er nb_trans) have been validated for transmission inside this microframe. this bit is reset by udphs_eptrst register ept_x (reset endpoint) and by udphs_eptctldisx (disable endpoint). ? nak_in/err_flush: nak in/bank flush error C nak_in : this bit is set by hardware when a nak handshake has bee n sent in response to an in request from the host. this bit is cleared by software.
885 6438fCatarmC21-jun-10 at91sam9g45 C err_flush : (for high bandwidth isochronous in endpoints) this bit is set when flushing unsent banks at the end of a microframe. this bit is reset by udphs_eptrst register ept_x (r eset endpoint) and by ept_ctl_disx (disable endpoint). ? nak_out: nak out this bit is set by hardware when a nak handshake has been sent in response to an out or ping request from the host. this bit is reset by udphs_eptrst register ept_x (r eset endpoint) and by ept_ctl_disx (disable endpoint). ? current_bank/control_dir: cu rrent bank/control direction C current bank : (all endpoints except control endpoint) these bits are set by hardware to indicate the number of the current bank. note: the current bank is updated each time the user: C sets the tx packet ready bit to prepare the next in transfer and to switch to the next bank. C clears the received out data bit to access the next bank. this bit is reset by udphs_eptrst register ept_x (reset endpoint) and by udphs_eptctldisx (disable endpoint). C control direction : (for control endpoint only) 0 = a control write is requested by the host. 1 = a control read is requested by the host. note1: this bit corresponds with the 7th bit of the bmrequesttype (byte 0 of the setup data). note2: this bit is updated after receiving new setup data. ? busy_bank_sta: busy bank number these bits are set by hardware to indicate the number of busy banks. in endpoint : it indicates the number of busy banks filled by the us er, ready for in transfer. out endpoint : it indicates the number of busy banks filled by out transaction from the host. 00 bank 0 (or single bank) 01 bank 1 10 bank 2 11 invalid 00 all banks are free 01 1 busy bank 10 2 busy banks 11 3 busy banks
886 6438fCatarmC21-jun-10 at91sam9g45 ? byte_count: udphs byte count byte count of a received data packet. this field is incremented after each write into the endpoint (to prepare an in transfer). this field is decremented after each reading into the endpoint (out transfer). this field is also updated at rx_bk_rdy flag clear with the next bank. this field is also updated at tx_pk_rdy flag set with the next bank. this field is reset by ept_x of udphs_eptrst register. ? shrt_pckt: short packet an out short packet is detected when the receive byte count is less than the configured udphs_eptcfgx register ept_size. this bit is updated at the same time as the byte_count field. this bit is reset by udphs_eptrst register ept_x (reset endpoint) and by udphs_eptctldisx (disable endpoint).
887 6438fCatarmC21-jun-10 at91sam9g45 38.6.18 udphs dma channel transfer descriptor the dma channel transfer descriptor is loaded from the memory. be careful with the alignment of this buffer. the structure of the dma channel transfer descriptor is defined by three parameters as described below: offset 0: the address must be aligned: 0xxxxx0 next descriptor address re gister: udphs_dmanxtdscx offset 4: the address must be aligned: 0xxxxx4 dma channelx address register: udphs_dmaaddressx offset 8: the address must be aligned: 0xxxxx8 dma channelx control register: udphs_dmacontrolx to use the dma channel transfer descriptor, fill the structures with the correct value (as described in the following pages). then write directly in udphs_dmanxtdscx the address of the descriptor to be used first. then write 1 in the ldnxt_dsc bit of udph s_dmacontrolx (load next channel transfer descriptor). the descriptor is automatically loaded upon endpointx request for packet transfer.
888 6438fCatarmC21-jun-10 at91sam9g45 38.6.19 udphs dma next de scriptor address register name: udphs_dmanxtdscx [x = 1..5] addresses: 0xfff78320 [1], 0xfff78330 [2], 0xfff78340 [3], 0xfff78350 [4], 0xfff78360 [5] access type: read-write ? nxt_dsc_add this field points to the next channel descri ptor to be processed. this channel descri ptor must be aligned, so bits 0 to 3 of the address must be equal to zero. 31 30 29 28 27 26 25 24 nxt_dsc_add 23 22 21 20 19 18 17 16 nxt_dsc_add 15 14 13 12 11 10 9 8 nxt_dsc_add 76543210 nxt_dsc_add
889 6438fCatarmC21-jun-10 at91sam9g45 38.6.20 udphs dma chan nel address register name: udphs_dmaaddressx [x = 1..5] addresses: 0xfff78324 [1], 0xfff78334 [2], 0xfff78344 [3], 0xfff78354 [4], 0xfff78364 [5] access type: read-write ? buff_add this field determines the ahb bus starting address of a dma channel transfer. channel start and end addresses may be aligned on any byte boundary. the firmware may write this field only when the udphs_dmastatus register chann_enb bit is clear. this field is updated at the end of the address phase of the current access to the ahb bus. it is incrementing of the access byte width. the access width is 4 bytes (or less) at packet start or end, if the start or end address is not aligned on a word boundary. the packet start address is either the channel start addres s or the next channel address to be accessed in the channel buffer. the packet end address is either the channel end address or the latest channel address accessed in the channel buffer. the channel start address is written by software or loaded fr om the descriptor, whereas the channel end address is either determined by the end of buffer or the udphs device, usb end of transfer if th e udphs_dmacontrolx register end_tr_en bit is set. 31 30 29 28 27 26 25 24 buff_add 23 22 21 20 19 18 17 16 buff_add 15 14 13 12 11 10 9 8 buff_add 76543210 buff_add
890 6438fCatarmC21-jun-10 at91sam9g45 38.6.21 udphs dma channel control register name: udphs_dmacontrolx [x = 1..5] addresses: 0xfff78328 [1], 0xfff78338 [2], 0xfff78348 [3], 0xfff78358 [4], 0xfff78368 [5] access type: read-write ? chann_enb (channel enable command) 0 = dma channel is disabled at and no transfer will occur upon request. this bit is also cl eared by hardware when the chan- nel source bus is disabled at end of buffer. if the udphs_dmacontrol register ldnx t_dsc bit has been cleared by descript or loading, the fi rmware will have to set the corresponding chann_enb bit to start the described transfer, if needed. if the udphs_dmacontrol register ldnxt_dsc bit is cl eared, the channel is frozen and the channel registers may then be read and/or written reliably as soon as both udphs_dmastatus register chann_enb and chann_act flags read as 0. if a channel request is currently serviced when this bit is clear ed, the dma fifo buffer is drained until it is empty, then the udphs_dmastatus register chann_enb bit is cleared. if the ldnxt_dsc bit is set at or after this bit clearing, then the currently loaded descriptor is skipped (no data transfer occurs) and the next descriptor is immediately loaded. 1 = udphs_dmastatus register chann_enb bit will be set, thus enabling dma channel da ta transfer. then any pend- ing request will start the transfer. this may be used to start or resume any requested transfer. ? ldnxt_dsc: load next channel transfer descriptor enable (command) 0 = no channel register is loaded after the end of the channel transfer. 1 = the channel controller loads the next descriptor after the end of the current transfer, i.e. when the udphs_dmastatus/chann_enb bit is reset. if the udphs_dma control/chann_enb bit is cleared, the next descriptor is immediately loaded upon transfer request. dma channel control command summary 31 30 29 28 27 26 25 24 buff_length 23 22 21 20 19 18 17 16 buff_length 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 burst_lck desc_ld_it end_buffit end_tr_it end_b_en end_tr_en ldnxt_dsc chann_enb ldnxt_dsc chann_enb description 0 0 stop now 0 1 run and stop at end of buffer 1 0 load next descriptor now 1 1 run and link at end of buffer
891 6438fCatarmC21-jun-10 at91sam9g45 ? end_tr_en: end of transfer enable (control) used for out transfers only. 0 = usb end of transfer is ignored. 1 = udphs device can put an end to the current buffer transfer. when set, a bulk or interrupt short packet or the last packet of an isoc hronous (micro) frame (datax) will close the current buffe r and the udphs_dmastatusx register end_tr_st flag will be raised. this is intended for udphs non-prenegotiated end of transfer (bulk or interrupt) or isochronous microframe data buffer closure. ? end_b_en: end of buffer enable (control) 0 = dma buffer end has no impact on usb packet transfer. 1 = endpoint can validate the packet (according to the valu es programmed in the udphs_eptctlx register auto_valid and shrt_pckt fields) at dma buffer end, i.e. when the udphs_dmastatus register buff_count reaches 0. this is mainly for short packet in validation initiated by the dma reaching end of buffer, but could be used for out packet truncation (discarding of unwanted packet data) at the end of dma buffer. ? end_tr_it: end of transfer interrupt enable 0 = udphs device initiated buffer transfer completion will not trigger any interrupt at udphs_statusx/end_tr_st rising. 1 = an interrupt is sent after the buffer transfer is complete, if the udphs device has ended the buffer transfer. use when the receive size is unknown. ? end_buffit: end of buffer interrupt enable 0 = udphs_dma_statusx/ end_bf_st rising will not trigger any interrupt. 1 = an interrupt is generated when the udphs_dmastatusx register buff_count reaches zero. ? desc_ld_it: descriptor loaded interrupt enable 0 = udphs_dmastatusx/desc_ldst risi ng will not trigge r any interrupt. 1 = an interrupt is generated when a descriptor has been loaded from the bus. ? burst_lck: burst lock enable 0 = the dma never locks bus access. 1 = usb packets ahb data bursts are locked for maximum opt imization of the bus bandwidth usage and maximization of fly-by ahb burst duration. ? buff_length: buffer byte length (write-only) this field determines the number of bytes to be transferred until end of buffer. the maximum channel transfer size (64 kbytes) is reached when this field is 0 (default value). if the tr ansfer size is unknown, this fi eld should be set to 0, but th e transfer end may occur earlier under udphs device control. when this field is written, the udphs_dmastatusx regi ster buff_count field is updated with the write value. note: bits [31:2] are only writable when issuin g a channel control command other than stop now. note: for reliability it is highly recommended to wait for bo th udphs_dmastatusx register chan_act and chan_enb flags are at 0, thus ensuring the channel has been stopp ed before issuing a command other than stop now.
892 6438fCatarmC21-jun-10 at91sam9g45 38.6.22 udphs dma chan nel status register name: udphs_dmastatusx [x = 1..5] addresses: 0xfff7832c [1], 0xfff7833c [2], 0xfff 7834c [3], 0xfff7835c [4], 0xfff7836c [5] access type: read-write ? chann_enb: channel enable status 0 = if cleared, the dma channel no longer transfers data, and may load the next descriptor if the udphs_dmacontrolx register ldnxt_dsc bit is set. when any transfer is ended either due to an elapsed byte count or a udphs device initiated transfer end, this bit is auto- matically reset. 1 = if set, the dma channel is currently enabled and transfers data upon request. this bit is normally set or cleared by writing into the udphs_dmacontrolx regist er chann_enb bit field either by soft- ware or descriptor loading. if a channel request is currently serviced when the udphs_ dmacontrolx register chan n_enb bit is cleared, the dma fifo buffer is drained until it is empty, then this status bit is cleared. ? chann_act: channel active status 0 = the dma channel is no longer trying to source the packet data. when a packet transfer is ended this bit is automatically reset. 1 = the dma channel is currently trying to source packet da ta, i.e. selected as the highest-priority requesting channel. when a packet transfer cannot be completed due to an end_bf_st, this flag stays set during the next channel descriptor load (if any) and potentially until udphs packet transfer completion, if allowed by the new descriptor. ? end_tr_st: end of channel transfer status 0 = cleared automatically when read by software. 1 = set by hardware when the last packet transfer is complete, if the udphs device has ended the transfer. valid until the chann_enb flag is cleared at the end of the next buffer transfer. ? end_bf_st: end of channel buffer status 0 = cleared automatically when read by software. 1 = set by hardware when the buff_count downcount reach zero. valid until the chann_enb flag is cleared at the end of the next buffer transfer. 31 30 29 28 27 26 25 24 buff_count 23 22 21 20 19 18 17 16 buff_count 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C desc_ldst end_bf_st end_tr_st C C chann_act chann_enb
893 6438fCatarmC21-jun-10 at91sam9g45 ? desc_ldst: descriptor loaded status 0 = cleared automatically when read by software. 1 = set by hardware when a descriptor has been loaded from the system bus. valid until the chann_enb flag is cleared at the end of the next buffer transfer. ? buff_count: buffer byte count this field determines the current number of bytes still to be transfer red for this buffer. this field is decremented from the ahb source bus access byte width at the end of this bus address phase. the access byte width is 4 by default, or less, at dma start or end, if the start or end address is not aligned on a word boundary. at the end of buffer, the dma accesses the udphs device only for the number of bytes needed to complete it. this field value is reliable (stable) only if the c hannel has been stopped or frozen (udphs_eptctlx register nt_dis_dma bit is used to disable the channel request) a nd the channel is no longer active chann_act flag is 0. note: for out endpoints, if the receive buffer byte length (b uff_length) has been defaulted to zero because the usb transfer length is unknown, the actual buffer by te length received will be 0x10000-buff_count.
894 6438fCatarmC21-jun-10 at91sam9g45
895 6438fCatarmC21-jun-10 at91sam9g45 39. image sensor interface (isi) 39.1 description the image sensor interface (isi) connects a cmos-type image sensor to the processor and provides image capture in various formats. it does data conversion, if necessary, before the stor- age in memory through dma. the isi supports color cmos image sensor and grayscale image sensors with a reduced set of functionalities. in grayscale mode, the data stream is stored in memory without any processing and so is not compatible with th e lcd controller. internal fifos on the preview and codec paths are used to store the incoming data. the rgb output on the preview path is compatible with the lcd controller. this module outputs the data in rgb format (lcd compatible) and has scaling capabilities to make it compliant to the lcd display resolution (see table 39-3 on page 898 ). several input formats such as preprocessed rgb or ycbcr are supported through the data bus interface. it supports two modes of synchronization: 1. the hardware with isi_vsync and isi_hsync signals 2. the international telecommunication union recommendation itu-r bt.656-4 start-of- active-video (sav) and end-of-active-video (eav) synchronization sequence. using eav/sav for synchronizatio n reduces the pin count (isi _vsync, isi_hsync not used). the polarity of the synchronization pulse is programmable to comply with the sensor signals. 39.2 embedded characteristics ? itu-r bt. 601/656 8-bit mode external interface support ? support for itu-r bt.656-4 sav and eav synchronization ? vertical and horizontal resolutions up to 2048 x 2048 ? preview path up to 640*480 ? support for packed data formatting for ycbcr 4:2:2 formats ? preview scaler to generate smaller size image table 39-1. i/o description signal dir description isi_vsync in vertical synchronization isi_hsync in horizontal synchronization isi_data[11..0] in sensor pixel data isi_mck out master clock provided to the image sensor isi_pck in pixel clock provided by the image sensor
896 6438fCatarmC21-jun-10 at91sam9g45 figure 39-1. isi connection example 39.3 block diagram figure 39-2. image sensor interface block diagram image sensor image sensor interface data[11..0] isi_data[11..0] clk isi_mck pclk isi_pck vsync hsync isi_vsync isi_hsync timing signals interface ccir-656 embedded timing decoder(sav/eav) pixel sampling module clipping + color conversion ycc to rgb 2-d image scaler pixel formatter rx direct display fifo core video arbiter camera ahb master interface apb interface camera interrupt controller config registers clipping + color conversion rgb to ycc rx direct capture fifo scatter mode support packed formatter frame rate ycbcr 4:2:2 8:8:8 5:6:5 rgb cmos sensor pixel input up to 12 bit hsync/len vsync/fen cmos sensor pixel clock input pixel clock domain ahb clock domain apb clock domain from rx buffers camera interrupt request line codec_on ahb bus apb bus
897 6438fCatarmC21-jun-10 at91sam9g45 39.4 functional description the image sensor interface (isi) supports di rect connection to the itu-r bt. 601/656 8-bit mode compliant sensors and up to 12-bit grayscale sensors. it receives the image data stream from the image sensor on the 12-bit data bus. this module receives up to 12 bits for data, the ho rizontal and vertical sy nchronizations and the pixel clock. the reduced pin count alternative for synchronization is supported for sensors that embed sav (start of active vide o) and eav (end of active video) delimiters in the data stream. the image sensor interface interrupt line is connected to the advanced interrupt controller and can trigger an interrupt at the beginning of each frame and at the end of a dma frame transfer. if the sav/eav synchronization is us ed, an interrupt ca n be triggered on each delimiter event. for 8-bit color sensors, the data stream received can be in several possible formats: ycbcr 4:2:2, rgb 8:8:8, rgb 5:6:5 and may be processed before the storage in memory. the data stream may be sent on both preview path and codec path if the bit isi_cdc in the isi_ctrl is one. to optimize the bandwidth, the codec path should be enabled only when a capture is required. in grayscale mode, the input data stream is stored in memory without any processing. the 12-bit data, which represent the grayscale level for the pixel, is stored in memory one or two pixels per word, depending on the gs_mode bit in the isi_cfg2 register. the codec datapath is not available when grayscale image is selected. a frame rate counter allows users to capture all frames or 1 out of every 2 to 8 frames. 39.4.1 data timing the two data timings using hori zontal and vertical synchroni zation and eav/sav sequence syn- chronization are shown in figure 39-3 and figure 39-4 . in the vsync/hsync synchronization, the valid da ta is captured with the active edge of the pixel clock (isi_pck), after sfd lines of vertical blanking and sld pixel clock periods delay pro- grammed in the control register. the itu-rbt.656-4 defines the functional timing for an 8-bit wide interface. there are two timing reference signals, one at the beginning of each video data block sav (0xff000080) and one at the end of each video data block eav(0xff00009d). only data sent between eav and sav is capt ured. horizontal blanking and vert ical blanking are ignored. use of the sav and eav synchronization eliminates the isi_vsync and isi_hsync signals from the interface, thereby reducing the pin count. in order to retrieve both frame and line synchronization properly, at least one line of vertical blanking is mandatory.
898 6438fCatarmC21-jun-10 at91sam9g45 figure 39-3. hsync and vsync synchronization figure 39-4. sav and eav sequence synchronization 39.4.2 data ordering the rgb color space format is required for viewing images on a display screen preview, and the ycbcr color space format is required for encoding. all the sensors do not output the ycbcr or rgb components in the same order. the isi allows the user to program the same component order as the sensor, reducing software treatments to restore the right format. isi_vsync isi_hsync isi_pck frame 1 line ycby crycb y crycby cr data[7..0] isii_pck cr y cb y cr y y cr y cb ff 00 data[7..0] ff 00 00 80 y cb y 00 9d sav eav active video table 39-2. data ordering in ycbcr mode mode byte 0 byte 1 byte 2 byte 3 default cb(i) y(i) cr(i) y(i+1) mode1 cr(i) y(i) cb(i) y(i+1) mode2 y(i) cb(i) y(i+1) cr(i) mode3 y(i) cr(i) y(i+1) cb(i) table 39-3. rgb format in default mode, rgb_cfg = 00, no swap mode byte d7 d6 d5 d4 d3 d2 d1 d0 rgb 8:8:8 byte 0 r7(i) r6(i) r5(i) r4(i) r3(i) r2(i) r1(i) r0(i) byte 1 g7(i) g6(i) g5(i) g4(i) g3(i) g2(i) g1(i) g0(i) byte 2 b7(i) b6(i) b5(i) b4(i) b3(i) b2(i) b1(i) b0(i) byte 3 r7(i+1) r6(i+1) r5(i+1) r4(i+1) r3(i+1) r2(i+1) r1(i+1) r0(i+1)
899 6438fCatarmC21-jun-10 at91sam9g45 the rgb 5:6:5 input format is processed to be displayed as rgb 5:6:5 format, compliant with the 16-bit mode of the lcd controller. 39.4.3 clocks the sensor master clock (isi_mck) can be generated either by the advanced power manage- ment controller (apmc) through a programmable clock output or by an external oscillator connected to the sensor. none of the sensors embed a power management c ontroller, so providing the clock by the apmc is a simple and efficient way to control power consumption of the system. care must be taken when programming the system clock. the isi has two clock domains, the system bus clock and the pixel clock provided by sensor. the two clock domains are not syn- chronized, but the system clock must be faster than pixel clock. rgb 5:6:5 byte 0 r4(i) r3(i) r2(i) r1(i) r0(i) g5(i) g4(i) g3(i) byte 1 g2(i) g1(i) g0(i) b4(i) b3(i) b2(i) b1(i) b0(i) byte 2 r4(i+1) r3(i+1) r2(i+1) r1(i+1) r0(i+1) g5(i+1) g4(i+1) g3(i+1) byte 3 g2(i+1) g1(i+1) g0(i+1) b4(i+1) b3(i+1) b2(i+1) b1(i+1) b0(i+1) table 39-3. rgb format in default mode, rgb_cfg = 00, no swap table 39-4. rgb format, rgb_cfg = 10 (mode 2), no swap mode byte d7 d6 d5 d4 d3 d2 d1 d0 rgb 5:6:5 byte 0 g2(i) g1(i) g0(i) r4(i) r3(i) r2(i) r1(i) r0(i) byte 1 b4(i) b3(i) b2(i) b1(i) b0(i) g5(i) g4(i) g3(i) byte 2 g2(i+1) g1(i+1) g0(i+1) r4(i+1) r3(i+1) r2(i+1) r1(i+1) r0(i+1) byte 3 b4(i+1) b3(i+1) b2(i+1) b1(i+1) b0(i+1) g5(i+1) g4(i+1) g3(i+1) table 39-5. rgb format in default mode, rgb_cfg = 00, swap activated mode byte d7 d6 d5 d4 d3 d2 d1 d0 rgb 8:8:8 byte 0 r0(i) r1(i) r2(i) r3(i) r4(i) r5(i) r6(i) r7(i) byte 1 g0(i) g1(i) g2(i) g3(i) g4(i) g5(i) g6(i) g7(i) byte 2 b0(i) b1(i) b2(i) b3(i) b4(i) b5(i) b6(i) b7(i) byte 3 r0(i+1) r1(i+1) r2(i+1) r3(i+1) r4(i+1) r5(i+1) r6(i+1) r7(i+1) rgb 5:6:5 byte 0 g3(i) g4(i) g5(i) r0(i) r1(i) r2(i) r3(i) r4(i) byte 1 b0(i) b1(i) b2(i) b3(i) b4(i) g0(i) g1(i) g2(i) byte 2 g3(i+1) g4(i+1) g5(i+1) r0(i+1) r1(i+1) r2(i+1) r3(i+1) r4(i+1) byte 3 b0(i+1) b1(i+1) b2(i+1) b3(i+1) b4(i+1) g0(i+1) g1(i+1) g2(i+1)
900 6438fCatarmC21-jun-10 at91sam9g45 39.4.4 preview path 39.4.4.1 scaling, deci mation (subsampling) this module resizes captured 8-bit color sensor images to fit the lcd display format. the resize module performs only downscaling. the same ra tio is applied for both horizontal and vertical resize, then a fractional decimation algorithm is applied. the decimation factor is a multiple of 1/16 and values 0 to 15 are forbidden. example: input 1280*1024 output = 640*480 hratio = 1280/640 = 2 vratio = 1024/480 = 2.1333 the decimation factor is 2 so 32/16. table 39-6. decimation factor dec value 0->15 16 17 18 19 ... 124 125 126 127 dec factor x 1 1.063 1.125 1.188 ... 7.750 7.813 7.875 7.938 table 39-7. decimation and scaler offset values input output 352*288 640*480 800*600 1280*1024 1600*1200 2048*1536 vga 640*480 fna1620324051 qvga 320*240 f1632406480102 cif 352*288 f162633566685 qcif 176*144 f 32 53 66 113 133 170
901 6438fCatarmC21-jun-10 at91sam9g45 figure 39-5. resize examples 39.4.4.2 color space conversion this module converts ycrcb or yuv pixels to rg b color space. clipping is performed to ensure that the samples value do not exceed the allowable range. the conversion matrix is defined below and is fully programmable: example of programmable value to convert ycrcb to rgb: an example of programmable value to convert from yuv to rgb: 1280 1024 480 640 32/16 decimation 1280 1024 288 352 56/16 decimation r g b c 0 0 c 1 c 0 c 2 ? c 3 ? c 0 c 4 0 yy off ? c b c boff ? c r c roff ? = r 1.164 y 16 ? () ? 1.596 c r 128 ? () ? + = g 1.164 y 16 ? () 0.813 c r 128 ? () ? ? 0.392 c b 128 ? () ? ? ? = b 1.164 y 16 ? () ? 2.107 c b 128 ? () ? + = ? ? ? ? ? ry 1.596 v ? + = gy 0.394 u ? ? 0.436 v ? ? = by 2.032 u ? + = ? ? ? ? ?
902 6438fCatarmC21-jun-10 at91sam9g45 39.4.4.3 memory interface preview datapath contains a data formatter that converts 8:8:8 pixel to rgb 5:6:5 format compli- ant with 16-bit format of the lcd controller. in general, when converting from a color channel with more bits to one with fewer bits, formatter module discards the lower-order bits. example: converting from rgb 8:8:8 to rgb 5:6:5, it discards the three lsbs from the red and blue chan- nels, and two lsbs from the green channel. when grayscale mode is enabled, two memory formats are supported. one mode supports 2 pixels per word, and the other mode supports 1 pixel per word. 39.4.4.4 fifo and dma features both preview and codec datapaths contain fifos. these asynchronous buffers are used to safely transfer formatted pixels from pixel clock domain to ahb clock domain. a video arbiter is used to manage fifo thresholds and triggers a relevant dma request through the ahb master interface. thus, depending on fifo state, a spec ified length burst is asserted. regarding ahb master interface, it supports scatter dma mode through linked list operation. this mode of oper- ation improves flexibility of image buffer location and allows the user to allocate two or more frame buffers. the destination frame buffers are defined by a series of frame buffer descriptors (fbd). each fbd controls the transfer of one entire frame and then optionally loads a further fbd to switch the dma operation at another frame buffer address. the fbd is defined by a series of three words. the first one defines the current frame buffer address (named dma_x_addr register), the second defines control information (named dma_x_ctrl regis- ter) and the third defines the next descriptor address (named dma_x_dscr). dma transfer mode with linked list support is available for both codec and preview datapath. the data to be transferred described by an fbd requires several burst accesses. in the example below, the use of 2 ping-pong frame buffers is described. 39.4.4.5 example the first fbd, stored at address 0x00030000, defines the location of the first frame buffer. this address is programmed in the isi user interface dma_p_dscr. to enable descriptor fetch operation dma_p_ctrl register must be set to 0x00000001. lli_0 and lli_1 are the two descriptors of the linked list. destination address: frame buffe r id0 0x02a000 (lli_0.dma_p_addr) transfer 0 control information, fetch and writeback: 0x00000003 (lli_0.dma_p_ctrl) next fbd address: 0x00030010 (lli_0.dma_p_dscr) second fbd, stored at address 0x00030010, defines the location of the second frame buffer. destination address: frame buffer id1 0x0003a000 (lli_1.dma_p_addr transfer 1 control information fetch and writeback: 0x00000003 (lli_1.dma_p_ctrl) next fbd address: 0x00030000, wrapping to first fbd (lli_1.dma_p_dscr) using this technique, several frame buffers can be configured through the linked list. figure 39-6 illustrates a typical three frame bu ffer application. frame n is ma pped to frame buffer 0, frame table 39-8. grayscale memory mapping configuration for 12-bit data gs_mode data[31:24] data[23:16] data[15:8] data[7:0] 0 p_0[11:4] p_0[3:0], 0000 p_1[11:4] p_1[3:0], 0000 1 p_0[11:4] p_0[3:0], 0000 0 0
903 6438fCatarmC21-jun-10 at91sam9g45 n+1 is mapped to frame buffer 1, frame n+2 is mapped to frame buffer 2, further frames wrap. a codec request occurs, and the full-size 4:2:2 encoded frame is stored in a dedicated memory space. figure 39-6. three frame buffers application and memory mapping 39.4.5 codec path 39.4.5.1 color space conversion depending on user selection, this module can be bypassed so that input ycrcb stream is directly connected to the format converter module. if the rgb input stream is selected, this mod- ule converts rgb to ycrcb color sp ace with the formulas given below: an example of coefficients is given below: frame n frame n+1 frame n+2 frame n-1 frame n+3 frame n+4 frame buffer 0 frame buffer 1 frame buffer 3 4:2:2 image full roi isi config space codec request codec done lcd memory space y c r c b c 0 c 1 c 2 c 3 c ? 4 c ? 5 c ? 6 c ? 7 c 8 r g b y off cr off cb off + = y 0.257 r ? 0.504 g 0.098 b 16 + ? + ? + = c r 0.439 r ? 0.368 g ? ? 0.071 b 128 + ? ? = c b 0.148 r ? ? 0.291 g 0.439 b 128 + ? + ? ? = ? ? ? ? ?
904 6438fCatarmC21-jun-10 at91sam9g45 39.4.5.2 memory interface dedicated fifos are used to support packed memory mapping. ycrcb pixel components are sent in a single 32-bit word in a contiguous space (packed). data is stored in the order of natural scan lines. planar mode is not supported. 39.4.5.3 dma features like preview datapath, codec datapath dma mode uses linked list operation.
905 6438fCatarmC21-jun-10 at91sam9g45 39.5 image sensor interface (isi) user interface note: several parts of the isi controller use the pixel clock prov ided by the image sensor (isi_pck ). thus the user must first p rogram the image sensor to provide this clock (isi_pck) before programming the image sensor controller. table 39-9. i register mapping offset register name register access reset value 0x00 isi configuration 1 register isi_cfg1 read-write 0x00000000 0x04 isi configuration 2 register isi_cfg2 read-write 0x00000000 0x08 isi preview size register isi_psize read-write 0x00000000 0x0c isi preview decimation factor register isi_pdecf read-write 0x00000010 0x10 isi csc ycrcb to rgb set 0 register isi_y2r_set0 read-write 0x6832cc95 0x14 isi csc ycrcb to rgb set 1 register isi_y2r_set1 read-write 0x00007102 0x18 isi csc rgb to ycrcb set 0 register isi_r2y_set0 read-write 0x01324145 0x1c isi csc rgb to ycrcb set 1 register isi_r2y_set1 read-write 0x01245e38 0x20 isi csc rgb to ycrcb set 2 register isi_r2y_set2 read-write 0x01384a4b 0x24 isi control register isi_ctrl write 0x00000000 0x28 isi status register isi_status read 0x00000000 0x2c isi interrupt enable register isi_inten write 0x00000000 0x30 isi interrupt disable register isi_intdis write 0x00000000 0x34 isi interrupt mask register isi_intmask read 0x00000000 0x38 dma channel enable register dma_cher write 0x00000000 0x3c dma channel disable register dma_chdr write 0x00000000 0x40 dma channel status register dma_chsr read 0x00000000 0x44 dma preview base address register dma_p_addr read-write 0x00000000 0x48 dma preview control register dma_p_ctrl read-write 0x00000000 0x4c dma preview descriptor address register dma_p_dscr read-write 0x00000000 0x50 dma codec base address register dma_c_addr read-write 0x00000000 0x54 dma codec control register dma_c_ctrl read-write 0x00000000 0x58 dma codec descriptor address register dma_c_dscr read-write 0x00000000 0xe4 write protection control register isi_wpcr read-write 0x00000000 0xe8 write protection status register isi_wpsr read 0x00000000 0x44-0xf8 reserved C C C 0xfc reserved C C C
906 6438fCatarmC21-jun-10 at91sam9g45 39.5.1 isi configuration 1 register register name: isi_cfg1 access type: read-write reset value: 0x00000000 ? hsync_pol: horizontal synchronization polarity 0: hsync active high. 1: hsync active low. ? vsync_pol: vertical synchronization polarity 0: vsync active high. 1: vsync active low. ? pixclk_pol: pixel clock polarity 0: data is sampled on rising edge of pixel clock. 1: data is sampled on fa lling edge of pixel clock. ? emb_sync: embedded synchronization 0: synchronization by hsync, vsync. 1: synchronization by embedded synchronization sequence sav/eav. ? crc_sync: embedded synchronization correction 0: no crc correction is performed on embedded synchronization. 1: crc correction is performed. if the correction is not possib le, the current frame is disc arded and the crc_err is set in the status register. ? frate: frame rate [0..7] 0: all the frames are captured, else one frame every frate+1 is captured. ? discr: disable codec request 0 = codec datapath dma interface requires a request to restart. 1 = codec datapath dma automatically restarts. 31 30 29 28 27 26 25 24 sfd 23 22 21 20 19 18 17 16 sld 15 14 13 12 11 10 9 8 C thmask full discr frate 76543210 crc_sync emb_sync C pixclk_pol vsync_pol hsync_pol C C
907 6438fCatarmC21-jun-10 at91sam9g45 ? full: full mode is allowed 1: both codec and preview datapaths are working simultaneously. ? thmask: threshold mask 0: only 4 beats ahb burst are allowed. 1: only 4 and 8 beats ahb burst are allowed. 2: 4, 8 and 16 beats ahb burst are allowed. ? sld: start of line delay sld pixel clock periods to wait before the beginning of a line. ? sfd: start of frame delay sfd lines are skipped at the beginning of the frame.
908 6438fCatarmC21-jun-10 at91sam9g45 39.5.2 isi configuration 2 register register name: isi_cfg2 access type: read-write reset value: 0x00000000 ? im_vsize: vertical size of the image sensor [0..2047]: vertical size = im_vsize + 1. ?gs_mode: 0: 2 pixels per word. 1: 1 pixel per word. ? rgb_mode: rgb input mode: 0: rgb 8:8:8 24 bits. 1: rgb 5:6:5 16 bits. ? grayscale: 0: grayscale mode is disabled. 1: input image is assumed to be grayscale coded. ?rgb_swap: 0: d7 -> r7. 1: d0 -> r7. the rgb_swap has no effect when the grayscale mode is enabled. ? col_space: color space for the image data 0: ycbcr. 1: rgb. ? im_hsize: horizontal size of the image sensor [0..2047] horizontal size = im_hsize + 1. 31 30 29 28 27 26 25 24 rgb_cfg ycc_swap - im_hsize 23 22 21 20 19 18 17 16 im_hsize 15 14 13 12 11 10 9 8 col_space rgb_swap grayscale rgb_mode gs_mode im_vsize 76543210 im_vsize
909 6438fCatarmC21-jun-10 at91sam9g45 ? ycc_swap: defines the ycc image data ? rgb_cfg: defines rgb pattern when rgb_mode is set to 1 if rgb_mode is set to rgb 8:8:8, th en rgb_cfg = 0 implies rgb color sequen ce, else it implies bgr color sequence. ycc_swap byte 0 byte 1 byte 2 byte 3 00: default cb(i) y(i) cr(i) y(i+1) 01: mode1 cr(i) y(i) cb(i) y(i+1) 10: mode2 y(i) cb(i) y(i+1) cr(i) 11: mode3 y(i) cr(i) y(i+1) cb(i) rgb_cfg byte 0 byte 1 byte 2 byte 3 00: default r/g(msb) g(lsb)/b r/g(msb) g(lsb)/b 01: mode1 b/g(msb) g(lsb)/r b/g(msb) g(lsb)/r 10: mode2 g(lsb)/r b/g (msb) g(lsb)/r b/g(msb) 11: mode3 g(lsb)/b r/g(msb) g(lsb)/b r/g(msb)
910 6438fCatarmC21-jun-10 at91sam9g45 39.5.3 isi preview register register name: isi_psize access type: read-write reset value: 0x00000000 ? prev_vsize: vertical size for the preview path vertical preview size = prev_vsize + 1 (480 max only in rgb mode). ? prev_hsize: horizontal size for the preview path horizontal preview size = prev_hsiz e + 1 (640 max only in rgb mode). 31 30 29 28 27 26 25 24 CCCCCC prev_hsize 23 22 21 20 19 18 17 16 prev_hsize 15 14 13 12 11 10 9 8 CCCCCC prev_vsize 76543210 prev_vsize
911 6438fCatarmC21-jun-10 at91sam9g45 39.5.4 isi preview decimation factor register register name: isi_pdecf access type: read-write reset value: 0x00000010 ? dec_factor: decimation factor dec_factor is 8-bit width, range is from 16 to 255. values from 0 to 16 do not perform any decimation. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 dec_factor
912 6438fCatarmC21-jun-10 at91sam9g45 39.5.5 isi color space conversion ycrcb to rgb set 0 register register name: isi_y2r_set0 access type: read-write reset value: 0x6832cc95 ? c0: color space conversion matrix coefficient c0 c0 element default step is 1/128, ranges from 0 to 1.9921875. ? c1: color space conversion matrix coefficient c1 c1 element default step is 1/128, ranges from 0 to 1.9921875. ? c2: color space conversion matrix coefficient c2 c2 element default step is 1/128, ranges from 0 to 1.9921875. ? c3: color space conversion matrix coefficient c3 c3 element default step is 1/128, ranges from 0 to 1.9921875. 31 30 29 28 27 26 25 24 c3 23 22 21 20 19 18 17 16 c2 15 14 13 12 11 10 9 8 c1 76543210 c0
913 6438fCatarmC21-jun-10 at91sam9g45 39.5.6 isi color space conversion ycrcb to rgb set 1 register register name: isi_y2r_set1 access type: read-write reset value: 0x00007102 ? c4: color space conversion matrix coefficient c4 c4 element default step is 1/128, ranges from 0 to 3.9921875. ? yoff: color space conversion luminance default offset 0: no offset. 1: offset = 128. ? croff: color space conversion red chrominance default offset 0: no offset. 1: offset = 16. ? cboff: color space conversion blue chrominance default offset 0: no offset. 1: offset = 16. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 C cboff croff yoff C C C c4 c4
914 6438fCatarmC21-jun-10 at91sam9g45 39.5.7 isi color space conversion rgb to ycrcb set 0 register register name: isi_r2y_set0 access type: read-write reset value: 0x01324145 ? c0: color space conversion matrix coefficient c0 c0 element default step is 1/256, from 0 to 0.49609375. ? c1: color space conversion matrix coefficient c1 c1 element default step is 1/128, from 0 to 0.9921875. ? c2: color space conversion matrix coefficient c2 c2 element default step is 1/512, from 0 to 0.2480468875. ? roff: color space conver sion red component offset 0: no offset. 1: offset = 16. 31 30 29 28 27 26 25 24 CCCCCCCroff 23 22 21 20 19 18 17 16 c2 15 14 13 12 11 10 9 8 c1 76543210 c0
915 6438fCatarmC21-jun-10 at91sam9g45 39.5.8 isi color space conversion rgb to ycrcb set 1 register register name: isi_r2y_set1 access type: read-write reset value: 0x01245e38 ? c3: color space conversion matrix coefficient c3 c0 element default step is 1/128, ranges from 0 to 0.9921875. ? c4: color space conversion matrix coefficient c4 c1 element default step is 1/256, ranges from 0 to 0.49609375. ? c5: color space conversion matrix coefficient c5 c1 element default step is 1/512, ranges from 0 to 0.2480468875. ? goff: color space conversion green component offset 0: no offset. 1: offset = 128. 31 30 29 28 27 26 25 24 CCCCCCCgoff 23 22 21 20 19 18 17 16 c5 15 14 13 12 11 10 9 8 c4 76543210 c3
916 6438fCatarmC21-jun-10 at91sam9g45 39.5.9 isi color space conversion rgb to ycrcb set 2 register register name: isi_r2y_set2 access type: read-write reset value: 0x01384a4b ? c6: color space conversion matrix coefficient c6 c6 element default step is 1/512, ranges from 0 to 0.2480468875. ? c7: color space conversion matrix coefficient c7 c7 element default step is 1/256, ranges from 0 to 0.49609375. ? c8: color space conversion matrix coefficient c8 c8 element default step is 1/128, ranges from 0 to 0.9921875. ? boff: color space conversi on blue component offset 0: no offset. 1: offset = 128. 31 30 29 28 27 26 25 24 CCCCCCCboff 23 22 21 20 19 18 17 16 c8 15 14 13 12 11 10 9 8 c7 76543210 c6
917 6438fCatarmC21-jun-10 at91sam9g45 39.5.10 isi control register register name: isi_ctrl access type: write reset value: 0x00000000 ? isi_en: isi module enable request write one to this field to enable the module. software must poll enable field in the isi_status register to verify that the command has successfully completed. ? isi_dis: isi module disable request write one to this field to disable the module. if both isi_en and isi_dis are asserted at the same time, the disable request is not taken into account. software must poll dis_done fiel d in the isi_status register to verify that the command has successfully completed. ? isi_srst: isi software reset request write one to this field to request a software reset of the module. software must poll srst field in the isi_status register to verify that the software request command has terminated. ? isi_cdc: isi codec request write one to this field to enable the codec datapath and capture a full resolution frame. a new request cannot be taken into account while cdc_pnd bit is ac tive in the isi_status register. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCisi_cdc 76543210 CCCCCisi_srstisi_disisi_en
918 6438fCatarmC21-jun-10 at91sam9g45 39.5.11 isi status register register name: isi_sr access type: read reset value: 0x00000000 ? enable (this bit is a status bit) 0: module is enabled. 1: module is disabled. ? dis_done: module disable request has terminated 1: disable request has completed. this flag is reset after a read operation. ? srst: module software reset request has terminated 1: software reset request has completed. this flag is reset after a read operation. ? cdc_pnd: pending codec request (this bit is a status bit) 0: indicates that no codec request is pending. 1: indicates that the request has been taken into account but cannot be serviced within the current frame. the operation is postponed to the next frame. ? vsync: vertical synchronization 1: indicates that a vertical synchronization has been de tected since the last read of the status register. ? pxfr_done: preview dma transfer has terminated. when set to one, this bit indicates that the data transfer on the preview channel has completed. this flag is reset after a read operation. ? cxfr_done: codec dma transfer has terminated. when set to one, this bit indicates that the data transfer on the codec channel has completed. this flag is reset after a read operation. ? sip: synchronization in progress (this is a status bit) when the status of the preview or codec dma channel is modified, a minimum amount of time is required to perform the clock domain synchronization. this bit is set when this operation occurs. no modifi cation of the channel status is allowed when this bit is set, to guarantee data integrity. 31 30 29 28 27 26 25 24 CCCCfr_ovr crc_err c_ovr p_ovr 23 22 21 20 19 18 17 16 CCCCsipCcxfr_donepxfr_done 15 14 13 12 11 10 9 8 CCCCCvsyncC cdc_pnd 76543210 CCCCCsrstdis_doneenable
919 6438fCatarmC21-jun-10 at91sam9g45 ? p_ovr: preview datapath overflow 0: no overflow 1: an overrun condition has occurred in input fifo on the preview path. the overrun happens when the fifo is full and an attempt is made to write a new sample to the fifo. this flag is reset after a read operation. ? c_ovr: codec datapath overflow 0: no overflow 1: an overrun condition has occurred in input fifo on the codec path. the overrun happens when the fifo is full and an attempt is made to write a new sample to the fifo. this flag is reset after a read operation. ? crc_err: crc synchronization error 0: no crc error in the embedded synchronization frame (sav/eav) 1: the crc_sync is enabled in the control register and an error has been detected and not corrected. the frame is dis- carded and the isi waits for a new one. this flag is reset after a read operation. ? fr_ovr: frame rate overrun 0: no frame overrun. 1: frame overrun, the current frame is being skipped because a vsync signal has been detected while flushing fifos. this flag is reset after a read operation.
920 6438fCatarmC21-jun-10 at91sam9g45 39.5.12 isi interrupt enable register register name: isi_ier access type: read-write reset value: 0x0 ? dis_done: disable done interrupt enable ? srst: software reset interrupt enable ? vsync: vertical synchr onization interrupt enable ? pxfr_done: preview dma transfer done interrupt enable ? cxfr_done: codec dma transfer done interrupt enable ? p_ovr: preview datapath overflow interrupt enable ? c_ovr: codec datapath overflow interrupt enable ? crc_err: embedded synchronization crc error interrupt enable ? fr_ovr: frame rate overflow interrupt enable 31 30 29 28 27 26 25 24 CCCCfr_ovr crc_err c_ovr p_ovr 23 22 21 20 19 18 17 16 CCCCCCcxfr_donepxfr_done 15 14 13 12 11 10 9 8 CCCCCvsyncCC 76543210 CCCCCsrstdis_doneC
921 6438fCatarmC21-jun-10 at91sam9g45 39.5.13 isi interrupt disable register register name: isi_idr access type: read-write reset value: 0x0 ? dis_done: disable done interrupt disable ? srst: software reset interrupt disable ? vsync: vertical synchroni zation interrupt disable ? pxfr_done: preview dma transf er done interrupt disable ? cxfr_done: codec dma transf er done interrupt disable ? p_ovr: preview datapath overflow interrupt disable ? c_ovr: codec datapath overflow interrupt disable ? crc_err: embedded synchronization crc error interrupt disable ? fr_ovr: frame rate overflow interrupt disable 31 30 29 28 27 26 25 24 CCCCfr_ovr crc_err c_ovr p_ovr 23 22 21 20 19 18 17 16 CCCCCCcxfr_donepxfr_done 15 14 13 12 11 10 9 8 CCCCCvsyncCC 76543210 CCCCCsrstdis_doneC
922 6438fCatarmC21-jun-10 at91sam9g45 39.5.14 isi interrupt mask register register name: isi_imr access type: read-write reset value: 0x0 ? dis_done: module disable operation completed 0: the disable completed interrupt is disabled. 1: the disable completed interrupt is enabled. ? srst: software reset completed 0: the software reset completed interrupt is disabled. 1: the software reset comple ted interrupt is enabled. ? vsync: vertical synchronization 0: the vertical synchroniz ation interrupt is enabled. 1: the vertical synchronizat ion interrupt is disabled. ? pxfr_done: preview dma transfer interrupt 0: the preview dma transfer completed interrupt is enabled 1: the preview dma transfer completed interrupt is disabled ? cxfr_done: codec dma transfer interrupt 0: the codec dma transfer completed interrupt is enabled 1: the codec dma transfer completed interrupt ? p_ovr: fifo preview overflow 0: the preview fifo overflow interrupt is disabled. 1: the preview fifo overflow interrupt is enabled. ? p_ovr: fifo codec overflow 0: the codec fifo overflow interrupt is disabled. 1: the codec fifo overflow interrupt is enabled. 31 30 29 28 27 26 25 24 CCCCfr_ovr crc_err c_ovr p_ovr 23 22 21 20 19 18 17 16 CCCCCCcxfr_donepxfr_done 15 14 13 12 11 10 9 8 CCCCCvsyncCC 76543210 CCCCCsrstdis_doneC
923 6438fCatarmC21-jun-10 at91sam9g45 ? crc_err: crc synchronization error 0: the crc error interrupt is disabled. 1: the crc error interrupt is enabled. ? fr_ovr: frame rate overrun 0: the frame overrun interrupt is disabled. 1: the frame overrun interrupt is enabled.
924 6438fCatarmC21-jun-10 at91sam9g45 39.5.15 dma channel enable register register name: dma_cher access type: write reset value: 0x00000000 ? p_ch_en: preview channel enable write one to this field to enable the preview dma channel. ? c_ch_en: codec channel enable write one to this field to enable the codec dma channel. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCc_ch_enp_ch_en
925 6438fCatarmC21-jun-10 at91sam9g45 39.5.16 dma channel disable register register name: dma_chdr access type: write reset value: 0x00000000 ? p_ch_dis write one to this field to disable the channel. poll p_ch_s in dma_chsr to verify that the preview channel status has been successfully modified. ? c_ch_dis write one to this field to disabled the channel. poll c_ch_s in dma_chsr to verify that the codec channel status has been successfully modified. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCc_ch_disp_ch_dis
926 6438fCatarmC21-jun-10 at91sam9g45 39.5.17 dma channel status register register name: dma_chsr access type: read reset value: 0x00000000 ? p_ch_s: 0: indicates that the preview dma channel is disabled 1: indicates that the preview dma channel is enabled. ? c_ch_s: 0: indicates that the codec dma channel is disabled. 1: indicates that the codec dma channel is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCc_ch_sp_ch_s
927 6438fCatarmC21-jun-10 at91sam9g45 39.5.18 dma preview base address register register name: dma_p_addr access type: read-write reset value: 0x00000000 ? p_addr: preview image base address. (this address is word aligned.) 31 30 29 28 27 26 25 24 p_addr 23 22 21 20 19 18 17 16 p_addr 15 14 13 12 11 10 9 8 p_addr 76543210 p_addr C C
928 6438fCatarmC21-jun-10 at91sam9g45 39.5.19 dma preview control register register name: dma_p_ctrl access type: read-write reset value: 0x00000000 ? p_fetch: descriptor fetch control field 0: preview channel fetch operation is disabled. 1: preview channel fetch operation is enabled. ? p_wb: descriptor writeback control field 0: preview channel writeback operation is disabled. 1: preview channel writeb ack operation is enabled. ? p_ien: transfer done flag control 0: preview transfer done flag generation is enabled. 1: preview transfer done flag generation is disabled. ? p_done: (this field is only updated in the memory.) 0: the transfer related to this descriptor has not been performed. 1: the transfer related to this descriptor has completed. this field is updated in memory at the end of the transfer, when writeback operation is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCp_donep_ienp_wbp_fetch
929 6438fCatarmC21-jun-10 at91sam9g45 39.5.20 dma preview descriptor address register register name: dma_p_dscr access type: read-write reset value: 0x00000000 ? p_dscr: preview descriptor base address (this address is word aligned.) 31 30 29 28 27 26 25 24 p_dscr 23 22 21 20 19 18 17 16 p_dscr 15 14 13 12 11 10 9 8 p_dscr 76543210 p_dscr C C
930 6438fCatarmC21-jun-10 at91sam9g45 39.5.21 dma codec base address register register name: dma_c_addr access type: read-write reset value: 0x00000000 ? c_addr: codec image base address (this address is word aligned.) 31 30 29 28 27 26 25 24 c_addr 23 22 21 20 19 18 17 16 c_addr 15 14 13 12 11 10 9 8 c_addr 76543210 c_addr C C
931 6438fCatarmC21-jun-10 at91sam9g45 39.5.22 dma codec control register register name: dma_c_ctrl access type: read-write reset value: 0x00000000 ? c_fetch: descriptor fetch control field 0: codec channel fetch operation is disabled. 1: codec channel fetch operation is enabled. ? c_wb: descriptor writeback control field 0: codec channel writeback operation is disabled. 1: codec channel writeback operation is enabled. ? c_ien: transfer done flag control 0: codec transfer done flag generation is enabled. 1: codec transfer done flag generation is disabled. ? c_done: (this field is only updated in the memory.) 0: the transfer related to this descriptor has not been performed. 1: the transfer related to this descriptor has completed. this field is updated in memory at the end of the transfer, when. writeback operation is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCc_donec_ienc_wbc_fetch
932 6438fCatarmC21-jun-10 at91sam9g45 39.5.23 dma codec descriptor address register register name: dma_c_dscr access type: read-write reset value: 0x00000000 ? c_dscr: codec descriptor base address (this address is word aligned.) 31 30 29 28 27 26 25 24 c_dscr 23 22 21 20 19 18 17 16 c_dscr 15 14 13 12 11 10 9 8 c_dscr 76543210 c_dscr C C
933 6438fCatarmC21-jun-10 at91sam9g45 39.5.24 isi write protection control register name: isi_wpcr access type: read-write ? wp_pen: write protection enable 0 = disables the write protec tion if wp_key corresponds. 1 = enables the write protection if wp_key corresponds. ? wp_key: write protection key password should be written at value 0x495349 (ascii code for isi). writing any other value in this field has no effect. 31 30 29 28 27 26 25 24 wp_key (0x49 => i) 23 22 21 20 19 18 17 16 wp_key (0x53 => s) 15 14 13 12 11 10 9 8 wp_key (0x49 => i) 76543210 wp_en
934 6438fCatarmC21-jun-10 at91sam9g45 39.5.25 isi write protection status register name: isi_wpsr access type: read-write ? wp_vsrc: write protec tion violation status ? wp_vsrc: write protection violation source 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 wp_vsrc 15 14 13 12 11 10 9 8 wp_vsrc 76543210 ---- wp_vs wp_vs 0000 no write protection violation occurred since the last read of this register (wp_sr). 0001 write protection detected unauthorized attempt to write a control register had occurred (since the last read). 0010 software reset had been performed while write protection was enabled (since the last read). 0011 both write protection violation and software reset with write protection enabled had occurred since the last read. other value reserved wp_vsrc 0000 no write protection violation occurred since the last read of this register (wp_sr). 0001 write access in isi_cfg1 while write protection was enabled (since the last read). 0010 write access in isi_cfg2 while write protection was enabled (since the last read). 0011 write access in isi_psize while write protection was enabled (since the last read). 0100 write access in isi_pdecf while write protection was enabled (since the last read). 0101 write access in isi_y2r_set0 while write protection was enabled (since the last read). 0110 write access in isi_y2r_set1 while write protection was enabled (since the last read). 0111 write access in isi_r2y_set0 while write protection was enabled (since the last read). 1000 write access in isi_r2y_set1 while write protection was enabled (since the last read). 1001 write access in isi_r2y_set2 while write protection was enabled (since the last read). other value reserved
935 6438fCatarmC21-jun-10 at91sam9g45 40. touch screen adc controller (tsadcc) 40.1 description the touch screen adc controller is based on a successive approximation register (sar) 10- bit analog-to-digital converter (adc). it also integrates: ? a 8-to-1 analog multiplexer for analog-to-digital conversions of up to 8 analog lines ? 4 power switches that measure both axis positions on the resistive touch screen panel ? 1 additional power switch and an embedded resistor that detects pen-interrupt and pen loss the conversions extend from 0v to tsadvref. the tsadcc supports an 8-bit or 10-bit resolution mode, and conversion results are reported in a common register for all channels, as well as in a channel-dedicated register. conversions can be started for all enabled channels, either by a software trigger, by detection of a rising edge on the external trigger pin tsadtrg or by an integrated programmable timer. when the touch screen is enabled, a timer-triggered sequencer automatically configures the power switches, performs the conversions and stores the results in dedicated registers. the tsadcc also integrates a sleep mode and a pen-detect mode and connects with one pdc channel. these features reduce both pow er consumption and processor intervention. the tsadcc timings, like the startup time and sample and hold time, are fully configurable. 40.2 embedded characteristics ? 8-channel adc ? support 4-wire resistive touch screen ? 10-bit 384 ksamples/sec. successi ve approximation register adc ? -3/+3 lsb integral non linearity, -2/+2 lsb differential non linearity ? integrated 8-to-1 multiplexer, offering eight independent 3.3v analog inputs ? external voltage reference for better accuracy on low voltage inputs ? individual enable and disable of each channel ? multiple trigger sources C hardware or software trigger C external trigger pin ? sleep mode and conversion sequencer C automatic wakeup on trigger and back to sleep mode after conversions of all enabled channels
936 6438fCatarmC21-jun-10 at91sam9g45 40.3 block diagram figure 40-1. tsadcc block diagram tsadc interrupt tsadc adtrg vddana advref gnd trigger selection adc control logic successive approximation register analog-to-digital converter timer user interface aic peripheral bridge apb pdc ad0x p ad1x m ad3y m gpad4 gpadx ad2y p pio touch screen switches touch screen sequencer memory controller tsadc clock pmc gpadx: last general-purpose adc channel defined by the number of channels .... analog multiplexer tsadcc
937 6438fCatarmC21-jun-10 at91sam9g45 40.4 signal description 40.5 product dependencies 40.5.1 power management the tsadc controller is not continuously clocked. the programmer must first enable the tsadc controller clock in the power management controller (pmc) before using the tsadc controller. however, if the application does not require tsadc controller operations, the tsadc controller clock can be stopped when not needed and be restarted later. configuring the tsadc controller does not require the tsadc controller clock to be enabled. 40.5.2 interrupt sources the tsadcc interrupt line is connected on one of the internal sources of the advanced inter- rupt controller. using the tsadcc interrupt requires the aic to be programmed first. 40.5.3 analog inputs the analog input pins can be multiplexed with pio lines. in this case, the assignment of the tsadcc input is automatically done as soon as the corresponding channel is enabled by writing the register tsadcc_cher. by default, after reset, the pio lines are configured as input with its pull-up enabled and the tsadcc inputs are connected to the gnd. 40.5.4 i/o lines the pin tsadtrg may be shared with other peripheral functions through the pio controller. in this case, the pio controller should be set accordingly to assign the pin tsadtrg to the tsadcc function. table 40-1. tsadcc pin description pin name description vddana analog power supply tsadvref reference voltage ad0x p analog input channel 0 or touch screen top channel ad1x m analog input channel 1 or touch screen bottom channel ad2y p analog input channel 2 or touch screen right channel ad3y m analog input channel 3 or touch screen left channel gpad4 - gpad7 general-purpose analog input channels 4 to 7 tsadtrg external trigger table 40-2. peripheral ids instance id tsadcc 20 table 40-3. i/o lines instance signal i/o line peripheral tsadcc tsadtrg pd28 a
938 6438fCatarmC21-jun-10 at91sam9g45 40.5.5 conversion performances for performance and electrical characteristics of the tsadcc, see the section electrical char- acteristics of the full datasheet. 40.6 analog-to-digital con verter functional description the tsadcc embeds a successive approximation register (sar) analog-to-digital converter (adc). the adc supports 8-bit or 10-bit resolutions. the conversion is performed on a full range betw een 0v and the reference voltage pin tsad- vref. analog inputs between these voltages convert to values based on a linear conversion. 40.6.1 adc resolution the adc supports 8-bit or 10-bit resolutions. the 8- bit selection is performed by setting the bit lowres in the tsadcc mode register. see section 40.11.2 tsadcc mode register on page 956 . by default, after a reset, the resolution is the highest and the data field in the tsadcc chan- nel data register x (x = 0..7) are fully used. by setting the bit lowres, the adc switches in the lowest resolution and the conversion results can be read in the eight lowest significant bits of the data registers. the two highest bits of the data field in the corresponding tsadcc_ cdr register and of the ldata field in the tsadcc_lcdr register read 0. moreover, when a pdc channel is connected to the tsadcc, 10-bit resolution sets the transfer request sizes to 16-bit. setting the bit lowres autom atically switches to 8-bit data transfers. in this case, the destination buffers are optimized. all the conversions for the touch screen forces the adc in 10-bit resolution, regardless of the lowres setting. further details are given in the section operating modes on page 946 . 40.6.2 adc clock the tsadcc uses the adc clock to perform conv ersions. converting a single analog value to a 10-bit digital data requires sample and hold clock cycles as defined in the field shtim of the tsadcc mode register and 10 adc clock cycles. the adc clock frequency is selected in the prescal field of the tsadcc mode register . the adc clock range is between mck/2, if presc al is 0, and mck/128, if prescal is set to 63 (0x3f). prescal must be programmed in order to provide an adc clock frequency accord- ing to the maximum sampling rate parameter given in the electrical characteristics section. 40.6.3 sleep mode the tsadcc sleep mode maximizes power saving by automatically deactivating the analog-to- digital converter cell when it is not being us ed for conversions. sleep mode is enabled by set- ting the bit sleep in tsadcc mode register . the sleep of the adc is automatic ally managed by th e conversion sequencer, which can auto- matically process the conversions of all channels at lowest power consumption. when a trigger occurs, the analog-to-digital conver ter cell is automatically activated. as the analog cell requires a start-up time, the logic waits during this time and then starts the conver- sion on the enabled channels. when all conversions are complete, the adc is deactivated until the next trigger.
939 6438fCatarmC21-jun-10 at91sam9g45 40.6.4 startup time the touch screen adc has a minimal startup time when it exits the sleep mode. as the adc clock depends on the application, the user has to program the field startup in the tsadcc mode register , which defines how many adc clock cycles to wait before pe rforming the first conversion of the sequence. the field startup can define a startup time between 8 and 1024 adc clock cycles by steps of 8. the user must assure that adc startup time giv en in the section electrical characteristics is covered by this wait time. 40.6.5 sample and hold time in the same way, a minimal sample and hold time is necessary for the tsadcc to guarantee the best converted final value between selection of two channels. this time depends on the input impedance of the analog input, but also on the output impedance of the driver providing the sig- nal to the analog input, as there is no input buffer amplifier. the sample and hold time has to be programmed through the bitfields shtim in the tsadcc mode register and tsshtim in the tsadcc touch screen register . the field shtim defines the number of adc cl ock cycles for an analog input, while the field tsshtim defines the number of adc clock cycles for a touch screen input. these both fields can define a sample and hold time between 1 and 16 adc clock cycles. the field tsshtim defines also the time the power switches of the touch screen are closed when the tsadcc performs a conversion for the touch screen. 40.7 touch screen 40.7.1 resistive touch screen principles a resistive touch screen is based on two resistive films, each one being fitted with a pair of elec- trodes, placed at the top and bottom on one film, and on the right and left on the other. between the two, there is a layer that acts as an insulator, but also enables contact when you press the screen. this is illustrated in figure 40-2 . the tsadc controller has the ability to perform without exte rnal components: ? position measurement ? pressure measurement ? pen detection
940 6438fCatarmC21-jun-10 at91sam9g45 figure 40-2. touch screen position measurement 40.7.2 position measurement method as shown in figure 40-2 , to detect the position of a contact, a supply is first applied from top to bottom. due to the linear resistance of the film, there is a voltage gradient from top to bottom. when a contact is performed on the screen, the voltage propagates at the point the two surfaces come into contact with the second film. if the input impedance on the right and left electrodes sense is high enough, the film does not affect this voltage, despite its resistive nature. for the horizontal direction, the same method is used, but by applying supply from left to right. the range depends on the supply voltage and on the loss in the switches that connect to the top and bottom electrodes. in an ideal world (linear, with no loss through switches), the horizontal position is equal to: vy m / vdd or vy p / vdd. the proposed implementation with on-chip power switches is shown in figure 40-3 . the voltage measurement at the output of the switch compensates for the switches loss. it is possible to correct for the switch loss by performing the operation: [vy p - vx m ] / [vx p - vx m ]. this requires additional measurements, as shown in figure 40-3 . x m x p y m y p x p x m y p vdd gnd volt horizontal position detection y p y m x p vdd gnd volt vertical position detection pen contact
941 6438fCatarmC21-jun-10 at91sam9g45 figure 40-3. touch screen switches implementation 40.7.3 pressure measurement method the method to measure the pressure (rp) applied to the touch screen is based on the knowl- edge of the x-panel resistance (rxp). three conversions (xpos,z1,z2) are necessary to determine the value of rp (zaxis resistance). rp = rxp*(xpos/1024)*[(z2/z1)-1] x p x m y m vddana y p vddana gnd gnd to the adc x p x m y p vddana gnd switch resistor switch resistor y p y m x p vddana gnd switch resistor switch resistor horizontal position detection vertical position detection
942 6438fCatarmC21-jun-10 at91sam9g45 40.7.4 pen detect method when there is no contact, it is not necessary to perform conversion. however, it is important to detect a contact by keeping the powe r consumption as low as possible. the proposed implementation polarizes the vertical panel by closing the switch on x p and ties the horizontal panel by an embedded resistor connected to y m . this resistor is enabled by a fifth switch. since there is no contact, no current is flowing and there is no related power consump- tion. as soon as a contact occurs, a current is flowing in the touch screen and a schmitt trigger detects the voltage in the resistor. the touch screen interrupt configuration is entered by programming the bit pendet in the tsadcc mode register . if this bit is written at 1, the switch on x p and the switch on the resis- tor are both closed, except when a touch screen conversion is in progress. to complete the circuit, a programmable debouncer is placed at the output of the schmitt trigger. this debouncer is programmable at 1 adc clock period, useful when the system is running at slow clock, or at up to 2 15 adc clock periods, but better used to filter noise on the touch screen panel when the system is running at high speed. the de bouncer length can be selected by programming the field pendbc in tsadcc mode register . x p x m vddana gnd switch resistor switch resistor xpos measure(yp) y p y m open circuit rp x p x m vddana gnd switch resistor switch resistor z1 measure(xp) y p y m open circuit rp x p x m vddana gnd switch resistor switch resistor z2 measure(xp) y p y m open circuit rp
943 6438fCatarmC21-jun-10 at91sam9g45 figure 40-4. touch screen pen detect the touch screen p en detect can be used to generate a tsadcc interrupt to wake up the sys- tem or it can be programmed to trig a conversion, so that a position can be measured as soon as a contact is detected if the tsadcc is programmed for an operating mode involving the touch screen. the pen detect generates two types of status, reported in the tsadcc status register : ? the bit pencnt is set as soon as a current flows for a time over the debouncing time as defined by pendbc and remains set until tsadcc_sr is read. ? the bit nocnt is set as soon as no current flows for a time over the debouncing time as defined by pendbc and remains set until tsadcc_sr is read. both bits are automatically cleared as soon as the status register tsadcc_sr is read, and can generate an interrupt by writing accordingly the tsadcc interrupt enable register . x p x m y m vddana y p vddana gnd gnd to the adc gnd pen interrupt debouncer pendbc
944 6438fCatarmC21-jun-10 at91sam9g45 40.8 conversion results when a conversion is completed, the resulting 8-bit or 10-bit digital value is right-aligned and stored in the tsadcc channel data register x (x = 0..7) of the current channel and in the tsadcc last converted data register . the channel eoc bit and the bit drdy in the tsadcc status register are both set. if the pdc channel is enabled, drdy rising triggers a data transfer. in any case, either eoc and drdy can trigger an interrupt. reading one of the tsadcc channel data register x (x = 0..7) registers clears the corre- sponding eoc bit. reading tsadcc last converted data register clears the drdy bit and the eoc bit corre- sponding to the last converted channel. figure 40-5. eocx and drdy flag behavior if the tsadcc channel data register x (x = 0..7) is not read before further incoming data is converted, the corresponding overrun error (ovre) flag is set in the tsadcc status register . in the same way, new data converted when drdy is high sets the bit govre (general overrun error) in the tsadcc status register . the ovre and govre flags are automatically cleared when the tsadcc status register is read. conversion time read the adc_cdrx eocx drdy read the adc_lcdr chx (adc_chsr) (adc_sr) (adc_sr) write the adc_cr with start = 1 write the adc_cr with start = 1 shtim conversion time shtim
945 6438fCatarmC21-jun-10 at91sam9g45 figure 40-6. govre and ovrex flag behavior warning: if the corresponding channel is disabled during a conversion or if it is disabled and then reenabled during a conversion, its associated data and its corresponding eoc and ovre flags in tsadcc_sr are unpredictable. eoc0 govre ch0 (adc_chsr) (adc_sr) (adc_sr) adtrg eoc1 ch1 (adc_chsr) (adc_sr) ovre0 (adc_sr) undefined data data a data b adc_lcdr undefined data data a adc_cdr0 undefined data data b adc_cdr1 data c data c conversion read adc_sr drdy (adc_sr) read adc_cdr1 read adc_cdr0 shtim conversion shtim conversion shtim
946 6438fCatarmC21-jun-10 at91sam9g45 40.9 conversion triggers conversions of the active analog channels are started with a software or a hardware trigger. the software trigger is pr ovided by writing the tsadcc control register with the bit start at 1. the hardware trigger ca n be selected by the filed trgm od in the tsadcc trigger register (tsadcc_trgr) between: ? an edge, either rising or falling or any, de tected on the external trigger pin tsadtrg ? the pen detect, depending on how the pendet bit is set in the tsadcc mode register ? a continuous trigger, meaning the tsadcc restarts the next sequence as soon as it finishes the current one, in this case, only one software trigger is required at the beginning ? a periodic trigger, which is defined by programming the field trgper in the tsadcc trigger register enabling hardware triggers does not disable the so ftware trigger functionality. thus, if a hard- ware trigger is selected, the star t of a conversion can still be in itiated by the so ftware trigger. 40.10 operating modes the touch screen adc controller features se veral operating modes, each defining a conver- sion sequence: ? the adc mode: at each trigger, all the enabled channels are converted ? the touch screen mode: at each trigger, the touch screen inputs are converted with the switches accordingly set and the results are processed and stored in the corresponding data registers ? the interleaved mode: at each trigger, the 8 conversions for the touch screen and the analog inputs conversions are performed. only the analog inputs results are managed by the pdc and the touch screen conversions can be performed less often than the analog inputs. the operating mode of the tsadcc is pr ogrammed in the field tsamod in the tsadcc mode register . the conversion sequences for each operating mode are described in the following paragraphs. the conversion sequencer, combined with the sleep modes, allows automatic processing with minimum processor intervention and optimized pow er consumption. in any case, the sequence starts with a trigger event. note: the reference voltage pins always remain connected in normal mode as in sleep mode. 40.10.1 adc mode in the adc mode, the active channels are defined by the tsadcc channel status register , which is defined by writing the tsadcc channel enable register and tsadcc channel dis- able register . the results are stored in the tsadcc channel data register x (x = 0..7) and in the tsadcc last converted data register , so that data transfers by using the pdc are possible. at each trigger, the following sequence is performed: 3. if sleep is set, wake up the adc cell and wait for the startup time. 4. if channel 0 is enabled, convert channe l 0 and store result in both tsadcc_cdr0 and tsadcc_lcdr.
947 6438fCatarmC21-jun-10 at91sam9g45 5. if channel 1 is enabled, convert channe l 1 and store result in both tsadcc_cdr1 and tsadcc_lcdr. 6. if channel 2 is enabled, convert channe l 2 and store result in both tsadcc_cdr2 and tsadcc_lcdr. 7. if channel 3 is enabled, convert channe l 3 and store result in both tsadcc_cdr3 and tsadcc_lcdr. 8. if channel 4 to channel 7 are enabled, convert the channels and store result in the cor- responding tsadcc_cdrx and tsadcc_lcdr. 9. if sleep is set, sleep down the adc cell. if the pdc is enabled, all the converted data are transferred contiguously in the memory buffer. the bit lowres defines which resolution is used, either 8-bit or 10-bit, and thus the width of the pdc memory buffer. 40.10.2 touch screen mode writing tsamod to touch screen only mode automatically enables the touch screen pins as analog inputs, and thus disables the di gital function of the corresponding pins. in touch screen mode, the channels 0 to 3 corresponding to the touch screen inputs are auto- matically activated and the bits ch0 to ch3 are automatically set in the tsadcc channel status register . the remaining channels can be either enabled or disabled by the user a nd their conversions are performed at the end of each touch screen sequence. the resolution is forced to 10 bits, regardless of the lowres bit setting. at each trigger, if the bit pres in tsadcc mode register is disabled, the following sequence is performed to measure only position. 1. if sleep is set, wake up the adc cell and wait for the startup time. 2. close the switches on the inputs x p and x m during the sample and hold time. 3. convert channel x m and store the resu lt in tsadcc_cdr1. 4. close the switches on the inputs x p and x m during the sample and hold time. 5. convert channel x p , subtract tsadcc_cdr1 from the result and store the subtraction result in both tsad cc_cdr0 and tsadcc_lcdr. 6. close the switches on the inputs x p and x m during the sample and hold time. 7. convert channel y p , subtract tsadcc_cdr1 from the result and store the subtraction result in both tsad cc_cdr1 and tsadcc_lcdr. 8. close the switches on the inputs y p and y m during the sample and hold time. 9. convert channel y m and store the resu lt in tsadcc_cdr3. 10. close the switches on the inputs y p and y m during the sample and hold time. 11. convert channel y p , subtract tsadcc_cdr3 from the result and store the subtraction result in both tsad cc_cdr2 and tsadcc_lcdr. 12. close the switches on the inputs y p and y m during the sample and hold time. 13. convert channel x p , subtract tsadcc_cdr3 from the result and store the subtraction result in both tsad cc_cdr3 and tsadcc_lcdr. 14. if channel 4 to channel 7 are enabled, convert the channels and store result in the cor- responding tsadcc_cdrx and tsadcc_lcdr. 15. if sleep is set, sleep down the adc cell. the resulting buffer is 16 bits wide and its structure stored in memory is:
948 6438fCatarmC21-jun-10 at91sam9g45 1. x p - x m 2. y p - x m 3. y p - y m 4. x p - y m 5. ad4 to ad7 if enabled. the vertical position can be easily calculated by dividing the data at offset 0 (x p - x m ) by the data at offset 1 (y p - x m ). the horizontal position can be easily calcul ated by dividing the data at offset 2 (y p - y m ) by the data at offset 3 (x p - y m ). if the bit pres in tsadcc mode register is enabled, the following sequence is performed to measure both position and pressure. 1. if sleep is set, wake up the adc cell and wait for the startup time. 2. close the switches on the inputs x m and y p during the sample and hold time. 3. convert channel x p and store the result in both tsadcc_z1dr and tsadcc_lcdr. 4. close the switches on the inputs x m and y p during the sample and hold time. 5. convert channel y m and store the result in both tsadcc_z2dr and tsadcc_lcdr. 6. close the switches on the inputs x p and x m during the sample and hold time. 7. convert channel x m and store the resu lt in tsadcc_cdr1. 8. close the switches on the inputs x p and x m during the sample and hold time. 9. convert channel x p, subtract tsadcc_cdr1 from the result and store the subtraction result in both tsad cc_cdr0 and tsadcc_lcdr. 10. close the switches on the inputs x p and x m during the sample and hold time. 11. convert channel y p and store the result in tsa dcc_xpdr, subtract tsadcc_cdr1 from the result and store the subtraction result in both tsadcc_cdr1 and tsadcc_lcdr. 12. close the switches on the inputs y p and y m during the sample and hold time. 13. convert channel y m and store the result in tsadcc _cdr3 while stor ing content of tsadcc_xpdr in tsadcc_lcdr. 14. close the switches on the inputs y p and y m during the sample and hold time. 15. convert channel y p subtract tsadcc_cdr3 from the re sult and store the subtraction result in both tsad cc_cdr2 and tsadcc_lcdr. 16. close the switches on the inputs y p and y m during the sample and hold time. 17. convert channel x p subtract tsadcc_cdr3 from the re sult and store the subtraction result in both tsad cc_cdr3 and tsadcc_lcdr. 18. if channel 4 to channel 7are enabled, convert the channels and store result in the cor- responding tsadcc_cdrx and tsadcc_lcdr 19. if sleep is set, sleep down the adc cell. the resulting buffer is 16 bits wide and its structure stored in memory is: 1. z1 2. z2 3. x p - x m 4. y p - x m 5. xpos 6. y p - y m
949 6438fCatarmC21-jun-10 at91sam9g45 7. x p - y m 8. ad4 to ad7 if enabled. the vertical position can be easily calculated by dividing the data at offset 2 (x p - x m ) by the data at offset 3(y p - x m ). the horizontal position can be easily calcul ated by dividing the data at offset 5 (y p - y m ) by the data at offset 7 (x p - y m ). the pressure measure can be calculated using the following formula rp = rxp*(xpos/1024)*[(z2/z1)-1] 40.10.3 interleaved mode in the interleaved mode, the conversion of the touch screen channels are made in parallel to each channel. in addition to interleaving, the analog channels 4 and 5 can be converted more often than the touch screen channels depending on the tsfreq field in the register tsadcc_mr. in the interleaved mode at least one adc channel must be enabled. in the interleaved mode, the channels 0 to 3 corr esponding to the touch screen inputs are auto- matically activated and the bits ch0 to ch3 are automatically set in the tsadcc channel status register . this mode allows periodic conversion of the re maining channels at high sampling rate and con- verted data transferred in memory with the pdc while the touch screen conversions are performed at low rate. the pdc transfers only analog channel data and touch screen data must be read in the tsadcc channel data register x (x = 0..7) . the resolution can be configured for the channel 4 to 7 only, through the lowres bit. the res- olution for the conversion made on channels 0 to 3 is forced to 10 bits. at each trigger, the sequence performed depends on a trigger counter, which is compared at the end to the touch screen frequency, as defined by the field tsfreq in the register tsadcc_mr: touch screen frequency = trigger frequency / (2 tsfreq+1 ) unless tsfreq is programmed at 0 or 1. in such cases, the touch screen frequency is one- sixth of the trigger frequency. as tsfreq varies between 0 and 15, this results in the adc channels being converted between 6 to 65536 less often than the touch screen channels. if the bit pres in tsadcc mode register is disabled (measure only position), the sequences are as follow: ? for trigger counter at 0: 1. close the switches on the inputs x p and x m during the sample and hold time. 2. convert channel x m and store the resu lt in tsadcc_cdr1. 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 1.
950 6438fCatarmC21-jun-10 at91sam9g45 ? for trigger counter at 1: 1. close the switches on the inputs x p and x m during the sample and hold time. 2. convert channel x p , subtract tsadcc_cdr1 from the result and store the subtraction result in tsadcc_cdr0 (and also in tsadcc_lcdr if pdcen is enabled). 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 2. ? for trigger counter at 2: 1. close the switches on the inputs x p and x m during the sample and hold time. 2. convert channel y p ,, subtract tsadcc_cdr1 from the result and store the subtrac- tion result in tsadcc_cdr1 (and also in tsadcc_lcd r if pdcen is enabled). 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 3. ? for trigger counter at 3: 1. close the switches on the inputs y p and y m during the sample and hold time. 2. convert channel y m and store the resu lt in tsadcc_cdr3. 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 4. ? for trigger counter at 4: 1. close the switches on the inputs y p and y m during the sample and hold time. 2. convert channel y p , subtract tsadcc_cdr3 from the result and store the subtraction result in tsadcc_cdr2 (and also in tsadcc_lcdr if pdcen is enabled). 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 5. ? for trigger counter at 5: 1. close the switches on the inputs y p and y m during the sample and hold time 2. convert channel x p , subtract tsadcc_cdr3 from the result and store the subtraction result in tsadcc_cdr3 (and also in tsadcc_lcdr if pdcen is enabled). 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 6. ? for trigger counter between 6 and (2 tsfreq+1 ): 1. increment trigger counter. 2. if trigger counter equals (2 tsfreq+1 ), then set trigger counter to 0.
951 6438fCatarmC21-jun-10 at91sam9g45 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. if the bit pres in tsadcc mode register is enabled (measure both position and pressure), the sequences are as follow: ? for trigger counter at 0: 1. close the switches on the inputs x p and y m during the sample and hold time. 2. convert channel x p and store the re sult in tsadcc_z1dr (and also in tsadcc_lcdr if pdcen is enabled). 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 1. ? for trigger counter at 1: 1. close the switches on the inputs x p and y m during the sample and hold time. 2. convert channel y m and store the result in tsadcc_z2dr (and also in tsadcc_lcdr if pdcen is enabled). 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 2. ? for trigger counter at 2: 1. close the switches on the inputs x p and x m during the sample and hold time. 2. convert channel x m and store the resu lt in tsadcc_cdr1. 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 3. ? for trigger counter at 3: 1. close the switches on the inputs x p and x m during the sample and hold time. 2. convert channel x p , subtract tsadcc_cdr1 from the result and store the subtraction result in tsadcc_cdr0 (and also in tsadcc_lcdr if pdcen is enabled). 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 4. ? for trigger counter at 4: 1. close the switches on the inputs x p and x m during the sample and hold time. 2. convert channel y p and store the result in tsa dcc_xpdr, subtract tsadcc_cdr1 from the result and store the subtracti on result in tsadcc_ cdr1 (and also in tsadcc_lcdr if pdcen is enabled). 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 5.
952 6438fCatarmC21-jun-10 at91sam9g45 ? for trigger counter at 5: 1. close the switches on the inputs y p and y m during the sample and hold time. 2. convert channel y m and store the result in tsadcc_cdr3 (and store content of tsadcc_xpdr in tsadcc_lcdr if pdcen is enabled). 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 6. ? for trigger counter at 6: 1. close the switches on the inputs y p and y m during the sample and hold time. 2. convert channel y p , subtract tsadcc_cdr3 from the result and store the subtraction result in tsadcc_cdr2 (and also in tsadcc_lcdr if pdcen is enabled). 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 7. ? for trigger counter at 7: 1. close the switches on the inputs y p and y m during the sample and hold time 2. convert channel x p , subtract tsadcc_cdr3 from the result and store the subtraction result in tsadcc_cdr3 (and also in tsadcc_lcdr if pdcen is enabled). 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. 4. set trigger counter to 8. ? for trigger counter between 8 and (2 tsfreq+1 ): 1. increment trigger counter. 2. if trigger counter equals (2 tsfreq+1 ), then set trigger counter to 0. 3. if channel 4 to channel 7 are enabled, convert channels and store result in the corre- sponding tsadcc_cdrx and tsadcc_lcdr. the trigger counter is cleared when tsamod is written to define the interleaved mode, then it simply rolls over. 40.10.4 manual mode the tsadcc features a manual mode allowing to control the state (open/close) of the four switches. writing tsamod to manual mode automatically enables the adc pins as analog inputs.the switches positions are controlled through the tsadcc manual switch command register . in this mode, the sample and hold time used is the one defined for the touchscreen mode (tsshtim). to perform a measurement, the following sequence must be followed 1. select the switch (switches) to close. 2. if sleep is set, wake up the adc cell and wait for the startup time.
953 6438fCatarmC21-jun-10 at91sam9g45 3. enable the channel to convert and start a conversion. if sleep is set, wake up the adc cell and wait for the startup time are performed before the conversion.the result is stored in tsadcc_cdrx (and t sadcc_lcdr if pdcen is enabled). 4. if sleep is set, sleep down the adc cell. 5. open the switches to reduce power consumption.
954 6438fCatarmC21-jun-10 at91sam9g45 40.11 touch screen adc controll er (tsadcc) user interface table 40-4. register mapping offset register name access reset 0x00 control register tsadcc_cr write-only C 0x04 mode register tsadcc_mr read-write 0x0000_0000 0x08 trigger register tsadcc_trgr read-write 0x0000_0000 0x0c touch screen register tsadcc_tsr read-write 0x0000_0000 0x10 channel enable register tsadcc_cher write-only C 0x14 channel disable register tsadcc_chdr write-only C 0x18 channel status register tsadcc_chsr read-only 0x0000_0000 0x1c status register tsadcc_sr read-only 0x000c_0000 0x20 last converted data register tsadcc_lcdr read-only 0x0000_0000 0x24 interrupt enable register tsadcc_ier write-only C 0x28 interrupt disable register tsadcc_idr write-only C 0x2c interrupt mask register tsadcc_imr read-only 0x0000_0000 0x30 channel data register 0 tsadcc_cdr0 read-only 0x0000_0000 0x34 channel data register 1 tsadcc_cdr1 read-only 0x0000_0000 0x38 channel data register 2 tsadcc_cdr2 read-only 0x0000_0000 0x3c channel data register 3 tsadcc_cdr3 read-only 0x0000_0000 0x40 channel data register 4 tsadcc_cdr4 read-only 0x0000_0000 0x44 channel data register 5 tsadcc_cdr5 read-only 0x0000_0000 0x48 channel data register 6 tsadcc_cdr6 read-only 0x0000_0000 0x4c channel data register 7 tsadcc_cdr7 read-only 0x0000_0000 0x50 x position data register tsadcc_xpdr read-only 0x0000_0000 0x54 z1 data register tsadcc_z1dr read-only 0x0000_0000 0x58 z2 data register tsadcc_z2dr read-only 0x0000_0000 0x5c reserved C C C 0x60 manual switch command register tsadcc_mscr read-write C reserved C C C 0xe4 write protection mode re gister tsadcc_wpmr read-write C 0xe8 write protection status register tsadcc_wpsr write-only C
955 6438fCatarmC21-jun-10 at91sam9g45 40.11.1 tsadcc control register register name: tsadcc_cr address: 0xfffb0000 access type: write-only ? swrst: software reset 0 = no effect. 1 = resets the tsadcc simulating a hardware reset. ? start: start conversion 0 = no effect. 1 = begins analog-to-digital conversion. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCC start swrst
956 6438fCatarmC21-jun-10 at91sam9g45 40.11.2 tsadcc mode register register name: tsadcc_mr address: 0xfffb0004 access type: read/write ? tsamod: touch screen adc mode ? pdcen: pdc transfer in touchscreen/interleaved mode or manual mode 0: disable the pdc transfer in touchscreen/interleaved mode or manual mode 1: in touchscreen/interleaved mode or manual mode, the data conversion is transferred in the tsadcc_lcdr register allowing pdc transfer to memory. ? lowres: resolution selection this option is only valid in adc mode. ? sleep: sleep mode ? prescal: prescaler rate selection adcclk = mck / ( (prescal+1) * 2 ) 31 30 29 28 27 26 25 24 pendbc shtim 23 22 21 20 19 18 17 16 Cstartup 15 14 13 12 11 10 9 8 prescal 76543210 pres pendet sleep lowres pdcen - tsamod tsamod touch screen adc operating mode 0 adc mode 1 touch screen only mode 2 interleaved mode 3 manual mode lowres selected resolution 0 10-bit resolution 1 8-bit resolution sleep selected mode 0 normal mode 1 sleep mode
957 6438fCatarmC21-jun-10 at91sam9g45 ? pendet: pen detect selection 0: disable the touch screen pins as analog inputs 1: enable the touch screen pins as analog inputs ? pres: pressure measurement selection 0: disable the pressure measurement function 1: enable the pressure measurement function ? startup: start up time startup time = (startup+1) * 8/adcclk ? shtim: sample & hold time for adc channels programming 0 for shtim gives a sample & hold time equal to 1/adcclk. sample & hold time = shtim/adcclk ? pendbc: pen detect debouncing period period = 2 pendbc /adcclk
958 6438fCatarmC21-jun-10 at91sam9g45 40.11.3 tsadcc trigger register register name: tsadcc_trgr address: 0xfffb0008 access type: read/write ? trgmod: trigger mode ? trgper: trigger period effective only if trgmod defines a periodic trigger defines the periodic trigger period, with the following equations: trigger period = (trgper+1) /adcclk 31 30 29 28 27 26 25 24 trgper 23 22 21 20 19 18 17 16 trgper 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCC trgmod trgmod selected trigger mode 0 0 0 no trigger, only software trigger can start conversions 0 0 1 external trigger rising edge 0 1 0 external trigger falling edge 0 1 1 external trigger any edge 1 0 0 pen detect trigger (shall be selected only if pendet is set and tsamod = touch screen only mode) 1 0 1 periodic trigger (trgper shall be initiated appropriately) 1 1 0 continuous mode 111reserved
959 6438fCatarmC21-jun-10 at91sam9g45 40.11.4 tsadcc touch screen register register name: tsadcc_tsr address: 0xfffb000c access type: read/write ? tsfreq: touch screen frequency in interleaved mode effective only if the touch screen interleaved mode is selected. defines the touch screen frequency compared to the trigger frequency. if tsfreq is 0 or 1, the touch screen frequ ency is a sixth of the trigger frequency. otherwise: touch screen frequency = trigger frequency / (2 tsfreq+1 ) ? tsshtim: sample & hold time for touch screen channels programming 0 for tsshtim gives a touch screen sample & hold time equal to 1/adcclk. touch screen sample & ho ld time = tsshtim/adcclk 31 30 29 28 27 26 25 24 CCCC tsshtim 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCC tsfreq
960 6438fCatarmC21-jun-10 at91sam9g45 40.11.5 tsadcc channel enable register register name: tsadcc_cher address: 0xfffb0010 access type: write-only ? chx: channel x enable 0 = no effect. 1 = enables the corresponding channel. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 ch7 ch6 ch5 ch4 ch3 ch2 ch1 ch0
961 6438fCatarmC21-jun-10 at91sam9g45 40.11.6 tsadcc channel disable register register name: tsadcc_chdr address: 0xfffb0014 access type: write-only ? chx: channel x disable 0 = no effect. 1 = disables the corresponding channel. warning: if the corresponding channel is disabled during a conversion or if it is disabled then reenabled during a conver- sion, its associated data and its corresponding eoc and ovre flags in tsadcc_sr are unpredictable. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 ch7 ch6 ch5 ch4 ch3 ch2 ch1 ch0
962 6438fCatarmC21-jun-10 at91sam9g45 40.11.7 tsadcc channel status register register name: tsadcc_chsr address: 0xfffb0018 access type: read-only ? chx: channel x status 0 = corresponding c hannel is disabled. 1 = corresponding channel is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 ch7 ch6 ch5 ch4 ch3 ch2 ch1 ch0
963 6438fCatarmC21-jun-10 at91sam9g45 40.11.8 tsadcc status register register name: tsadcc_sr address: 0xfffb001c access type: read-only ? eocx: end of conversion x 0 = corresponding analog channel is disabl ed, or the conversion is not finished. 1 = corresponding analog channel is enabled and conversion is complete. ? ovrex: overrun error x 0 = no overrun error on the corresponding channel since the last read of tsadcc_sr. 1 = there has been an overrun error on the corres ponding channel since the last read of tsadcc_sr. ? drdy: data ready 0 = no data has been converted since the last read of tsadcc_lcdr. 1 = at least one data has been converted and is available in tsadcc_lcdr. ? govre: general overrun error 0 = no general overrun error occurred since the last read of tsadcc_sr. 1 = at least one general overrun error has occurred since the last read of tsadcc_sr. ? endrx: end of rx buffer 0 = the receive counter re gister has not reached 0 since the last write in tsadcc_rcr or tsadcc_rncr. 1 = the receive counter register has reached 0 si nce the last write in tsadcc_rcr or tsadcc_rncr. ? rxbuff: rx buffer full 0 = tsadcc_rcr or tsadcc_rncr have a value other than 0. 1 = both tsadcc_rcr and tsadcc_rncr have a value of 0. ? pencnt: pen contact 0 = no contact has been detected since the last read of tsadcc_sr or pendet is at 0. 1 = at least one contact has been detected since the last read of tsadcc_sr. ? nocnt: no contact 0 = no contact loss has been detected since the last read of tsadcc_sr or pendet is at 0. 1 = at least one contact loss has been dete cted since the last read of tsadcc_sr. 31 30 29 28 27 26 25 24 C ovrez2 ovrez1 ovrexp C eocz2 eocz1 eocxp 23 22 21 20 19 18 17 16 C C nocnt pencnt rxbuff endrx govre drdy 15 14 13 12 11 10 9 8 ovre7 ovre6 ovre5 ovre4 ovre3 ovre2 ovre1 ovre0 76543210 eoc7 eoc6 eoc5 eoc4 eoc3 eoc2 eoc1 eoc0
964 6438fCatarmC21-jun-10 at91sam9g45 ? eocxp: end of conversion x position 0 = the pressure measurement is disabled or the xp conversion is not finished. 1 = the pressure measurement is enabled and the xp conversion is complete ? eocz1: end of conversion z1 measure 0 = the pressure measurement is disabled or the z1 conversion is not finished. 1 = the pressure measurement is enabled and the z1 conversion is complete ? eocz2: end of conversion z2 measure 0 = the pressure measurement is disabled or the z2 conversion is not finished. 1 = the pressure measurement is enabled and the z2 conversion is complete ? ovrexp: overrun error on x position 0 = no overrun error on the xp measure channel. 1 = there has been an overrun error on the xp measure channel. ? ovrez1: overrun error on z1 measure 0 = no overrun error on the z1 measure channel. 1 = there has been an overrun error on the z1 measure channel. ? ovrez2: overrun error on z2 measure 0 = no overrun error on the z2 measure channel. 1 = there has been an overrun error on the z2 measure channel.
965 6438fCatarmC21-jun-10 at91sam9g45 40.11.9 tsadcc channel data register x (x = 0..7) register name: tsadcc_cdr0..tsadcc_cdr7 address: 0xfffb0030 access type: read-only ? data: channel data the analog-to-digital conversion data is placed into this regi ster at the end of a conversion of the corresponding channel and remains until a new conversion on the same channel is completed. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCC data 76543210 data
966 6438fCatarmC21-jun-10 at91sam9g45 40.11.10 tsadcc last converted data register register name: tsadcc_lcdr address: 0xfffb0020 access type: read-only ? ldata: last data converted the analog-to-digital conversion data is placed into this r egister at the end of a conversion on any analog channel and remains until a new conversion on any analog channel is completed. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCC ldata 76543210 ldata
967 6438fCatarmC21-jun-10 at91sam9g45 40.11.11 tsadcc interrupt enable register register name: tsadcc_ier address: 0xfffb0024 access type: write-only ? eocx: end of conversion interrupt enable x ? ovrex: overrun error interrupt enable x ? drdy: data ready interrupt enable ? govre: general overrun error interrupt enable ? endrx: end of receive buffer interrupt enable ? rxbuff: receive buffer full interrupt enable ? pencnt: pen contact ? nocnt: no contact ? eocxp: end of conversion x position ? eocz1: end of conversion z1 measure ? eocz2: end of conversion z2 measure ? ovrexp: overrun error inte rrupt enable x position ? ovrez1: overrun error interrupt enable z1 measure ? ovrez2: overrun error interrupt enable z2 measure 0 = no effect. 1 = enables the corresponding interrupt. 31 30 29 28 27 26 25 24 C ovrez2 ovrez1 ovrexp C eocz2 eocz1 eocxp 23 22 21 20 19 18 17 16 C C nocnt pencnt rxbuff endrx govre drdy 15 14 13 12 11 10 9 8 ovre7 ovre6 ovre5 ovre4 ovre3 ovre2 ovre1 ovre0 76543210 eoc7 eoc6 eoc5 eoc4 eoc3 eoc2 eoc1 eoc0
968 6438fCatarmC21-jun-10 at91sam9g45 40.11.12 tsadcc interrupt disable register register name: tsadcc_idr address: 0xfffb0028 access type: write-only ? eocx: end of conversion interrupt disable x ? ovrex: overrun error interrupt disable x ? drdy: data ready interrupt disable ? govre: general overrun error interrupt disable ? endrx: end of receive buffer interrupt disable ? rxbuff: receive buffer full interrupt disable ? pencnt: pen contact ? nocnt: no contact ? eocxp: end of conversion x position ? eocz1: end of conversion z1 measure ? eocz2: end of conversion z2 measure ? ovrexp: overrun error inte rrupt disable x position ? ovrez1: overrun error interrupt disable z1 measure ? ovrez2: overrun error interrupt disable z2 measure 0 = no effect. 1 = disables the corresponding interrupt. 31 30 29 28 27 26 25 24 C ovrez2 ovrez1 ovrexp C eocz2 eocz1 eocxp 23 22 21 20 19 18 17 16 C C nocnt pencnt rxbuff endrx govre drdy 15 14 13 12 11 10 9 8 ovre7 ovre6 ovre5 ovre4 ovre3 ovre2 ovre1 ovre0 76543210 eoc7 eoc6 eoc5 eoc4 eoc3 eoc2 eoc1 eoc0
969 6438fCatarmC21-jun-10 at91sam9g45 40.11.13 tsadcc interrupt mask register register name: tsadcc_imr address: 0xfffb002c access type: read-only ? eocx: end of conversion interrupt mask x ? ovrex: overrun erro r interrupt mask x ? drdy: data ready interrupt mask ? govre: general overrun error interrupt mask ? endrx: end of receive buffer interrupt mask ? rxbuff: receive buffer full interrupt mask ? pencnt: pen contact ? nocnt: no contact ? eocxp: end of conversion x position ? eocz1: end of conversion z1 measure ? eocz2: end of conversion z2 measure ? ovrexp: overrun error in terrupt mask x position ? ovrez1: overrun error interrupt mask z1 measure ? ovrez2: overrun error interrupt mask z2 measure 0 = the corresponding interrupt is disabled. 1 = the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 C ovrez2 ovrez1 ovrexp C eocz2 eocz1 eocxp 23 22 21 20 19 18 17 16 C C nocnt pencnt rxbuff endrx govre drdy 15 14 13 12 11 10 9 8 ovre7 ovre6 ovre5 ovre4 ovre3 ovre2 ovre1 ovre0 76543210 eoc7 eoc6 eoc5 eoc4 eoc3 eoc2 eoc1 eoc0
970 6438fCatarmC21-jun-10 at91sam9g45 40.11.14 tsadcc x position data register register name: tsadcc_xpdr. address: 0xfffb0050 access type: read-only ? data: x position data 40.11.15 tsadcc z1 data register register name: tsadcc_z1dr. address: 0xfffb0054 access type: read-only ? data: z1 measurement data 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCC data 76543210 data 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCC data 76543210 data
971 6438fCatarmC21-jun-10 at91sam9g45 40.11.16 tsadcc z2 data register register name: tsadcc_z2dr. address: 0xfffb0058 access type: read-only ? data: z2 measurement data 40.11.17 tsadcc manual switch command register register name: tsadcc_mscr. address: 0xfffb0060 access type: read-only ? y m, y p, x m, x p : switch command if bit is set the related switch is closed if bit is cleared the related switch is open 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCC z2 76543210 z2 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCC 76543210 CCCC y m y p x m x p
972 6438fCatarmC21-jun-10 at91sam9g45 40.11.18 tsadcc write protection mode register register name: tsadcc_wpmr address: 0xfffb00e4 access type: read-write ? wpen: write protection of tsadcc_mr, tsadcc_trgr and tsadcc_tsr 0 and key= 0x545341 write protection is disabled. 1 and key = 0x545341, write protection is enabled. 40.11.19 tsadcc write protection status register register name: tsadcc_wpsr address: 0xfffb00e8 access type: read-write ? wps: write protection status 0: write protection is disabled. 1:write protection is enabled. ? offset_err: offset error offset where the last unauthorized access occurred. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 key 15 14 13 12 11 10 9 8 key 76543210 CCCCCCC wpen 31 30 29 28 27 26 25 24 offset_err 23 22 21 20 19 18 17 16 offset_err 15 14 13 12 11 10 9 8 offset_err 76543210 CCCCCCC wps
973 6438fCatarmC21-jun-10 at91sam9g45 41. dma controller (dmac) 41.1 description the dma controller (dmac) is an ahb-central dma controller core that transfers data from a source peripheral to a destination peripheral over one or more amba buses. one channel is required for each source/destination pair. in the most basic configuration, the dmac has one master interface and one channel. the master interface reads the data from a source and writes it to a destination. two amba transfers are required for each dmac data transfer. this is also known as a dual-access transfer. the dmac is programmed via the apb interface. 41.2 embedded characteristics ?two masters ? embeds 8 channels ? 64 bytes/fifo for channel buffering ? linked list support with status write back operation at end of transfer ? word, halfword, byte transfer support. ? memory to memory transfer ? peripheral to memory ? memory to peripheral the dma controller can handle the transfer between peripherals and memory and so receives the triggers from the peripherals below. the hardware interface numbers are also given below in table 41-1 ? acting as two matrix masters ? embeds 8 unidirectional channels with programmable priority table 41-1. dma channel definition instance name t/r dma channel hw interface number mci0 tx/rx 0 spi0 tx 1 spi0 rx 2 spi1 tx 3 spi1 rx 4 ssc0 tx 5 ssc0 rx 6 ssc1 tx 7 ssc1 rx 8 ac97c tx 9 ac97c rx 10 mci1 tx/rx 13
974 6438fCatarmC21-jun-10 at91sam9g45 ? address generation C source/destination address programming C address increment, decrement or no change C dma chaining support for multiple non-contiguous data blocks through use of linked lists C scatter support for placing fields into a system memory area from a contiguous transfer. writing a stream of data into non-contiguous fields in system memory C gather support for extracting fields from a system memory area into a contiguous transfer C user enabled auto-reloading of source, destination and control registers from initially programmed values at the end of a block transfer C auto-loading of source, destination and co ntrol registers from system memory at end of block transfer in block chaining mode C unaligned system address to data transfer width supported in hardware ? channel buffering C 16-word fifo C automatic packing/unpacking of data to fit fifo width ? channel control C programmable multiple transaction size for each channel C support for cleanly disabling a channel without data loss C suspend dma operation C programmable dma lock transfer support ? transfer initiation C support for software handshaking interface. memory mapped registers can be used to control the flow of a dma transfer in place of a hardware handshaking interface ? interrupt C programmable interrupt generation on dma transfer completion block transfer completion, single/multiple transaction completion or error condition
975 6438fCatarmC21-jun-10 at91sam9g45 41.3 block diagram figure 41-1. dma controller (dmac) block diagram dma destination dma channel 0 dma destination control state machine destination pointer management dma source control state machine source pointer management dma fifo controller dma fifo up to 64 bytes dma channel 0 read data path from source dma channel 0 write data path to destination dma channel 1 dma channel 2 dma channel n external triggers soft triggers dma req/ack interface trigger manager dma interrupt controller status registers configuration registers atmel apb rev2 interface dma ahb lite master interface 0 dma ahb lite master interface 1 dma global control and data mux dma global request arbiter dma global control and data mux dma global request arbiter dma destination requests pool dma write datapath bundles dma source requests pool dma read datapath bundles dma atmel apb interface dma interrupt dma hardware handshaking interface amba ahb layer 0 amba ahb layer 1
976 6438fCatarmC21-jun-10 at91sam9g45 41.4 functional description 41.4.1 basic definitions source peripheral: device on an amba layer from where the dmac reads data, which is then stored in the channel fifo. the source peripheral teams up with a destination peripheral to form a channel. destination peripheral: device to which the dmac writes the stored data from the fifo (previ- ously read from the source peripheral). memory: source or destination that is always ready for a dmac transfer and does not require a handshaking interface to interact with the dmac. channel: read/write datapath between a source peripheral on one configured amba layer and a destination peripheral on the same or different amba layer that occurs through the channel fifo. if the source peripheral is not memory, th en a source handshaking interface is assigned to the channel. if the destination peripheral is not memory, then a destination handshaking inter- face is assigned to the channel. source and de stination handshaking interfaces can be assigned dynamically by programming the channel registers. master interface: dmac is a master on the ahb bus reading data from the source and writing it to the destination over the ahb bus. slave interface: the apb interface over which the dmac is programmed. the slave interface in practice could be on the same layer as any of the master interfaces or on a separate layer. handshaking interface: a set of signal registers that conform to a protocol and handshake between the dmac and source or destination peri pheral to control the transfer of a single or chunk transfer between them. this interface is used to request, acknowledge, and control a dmac transaction. a channel can receive a r equest through one of two types of handshaking interface: hardware or software. hardware handshaking interface: uses hardware signals to control the transfer of a single or chunk transfer between the dmac and the source or destination peripheral. software handshaking interface: uses software registers to contr5ol the transfer of a single or chunk transfer between the dmac and the source or destination peripheral. no special dmac handshaking signals are needed on the i/o of the peripheral. this mode is useful for interfacing an existing peripheral to the dmac without modifying it. flow controller: the device (either the dmac or source/destination peripheral) that determines the length of and terminates a dmac buffer transfer. if the length of a buffer is known before enabling the channel, then the dmac should be programmed as the flow controller. if the length of a buffer is not known prior to enabling the c hannel, the source or destination peripheral needs to terminate a buffer transfer. in this mode, the peripheral is the flow controller. transfer hierarchy: figure 41-2 on page 977 illustrates the hierarchy between dmac transfers, buffer transfers, chunk or single, and amba transfers (single or burst) for non-memory peripher- als. figure 41-3 on page 977 shows the transfer hierarchy for memory.
977 6438fCatarmC21-jun-10 at91sam9g45 figure 41-2. dmac transfer hierarchy for non-memory peripheral figure 41-3. dmac transfer hierarchy for memory buffer: a buffer of dmac data. the amount of data (length) is determined by the flow controller. for transfers between the dmac and memory, a buffer is broken directly into a sequence of amba bursts and amba single transfers. for transfers between the dmac and a non-memory peripheral, a buffer is broken into a sequence of dmac transactions (single and chunks). these are in turn broken into a sequence of amba transfers. transaction: a basic unit of a dmac transfer as determined by either the hardware or software handshaking interface. a transaction is only relevant for transfers between the dmac and a source or destination peripheral if the source or destination peripheral is a non-memory device. there are two types of transactions: single transfer and chunk transfer. C single transfer: the length of a single transaction is always 1 and is converted to a single amba access. C chunk transfer: the length of a chunk is programmed into the dmac. the chunk is then converted into a sequence of ahb access.dmac executes each amba burst transfer by performing incremental bursts that are no longer than 16 beats. dmac transfer: software controls the number of buffers in a dmac transfer. once the dmac transfer has completed, then hardware within the dmac disables the channel and can generate hdma transfer dma transfer level buffer buffer buffer buffer transfer level chunk transfer chunk transfer chunk transfer single transfer dma transaction level burst transfer amba burst transfer amba burst transfer amba single transfer amba amba transfer level single transfer amba hdma transfer dma transfer level buffer buffer buffer buffer transfer level burst transfer amba burst transfer amba burst transfer amba single transfer amba amba transfer level
978 6438fCatarmC21-jun-10 at91sam9g45 an interrupt to signal the completion of the dmac transfer. you can then re-program the channel for a new dmac transfer. single-buffer dmac transfer: consists of a single buffer. multi-buffer dmac transfer: a dmac transfer may consist of multiple dmac buffers. multi-buf- fer dmac transfers are supported through buffer chaining (linked list pointers), auto-reloading of channel registers, and contiguous buffers. the source and destination can independently select which method to use. C linked lists (buffer chaining) ? a descriptor pointer (dscr) points to the location in system memory where the next linked list item (lli) exists. the lli is a set of registers that describe the next buffer (buffer descriptor) and a descriptor pointer register. the dmac fetches the lli at the beginning of every buffer when buffer chaining is enabled. C replay ? the dmac automatically reloads the channel registers at the end of each buffers to the value when the channel was first enabled. C contiguous buffers ? where the address of the next buffer is selected to be a continuation from the end of the previous buffer. picture-in-picture mode: dmac contains a picture-in-picture mode support. when this mode is enabled, addresses are automatically incremented by a programmable value when the dmac channel transfer count reaches a user defined boundary. figure 41-4 on page 978 illustrates a memory mapped image 4:2:2 encoded located at image_base_address in memory. a user defined start address is defined at picture_start_address. the incremented value is set to memory_hole_size = image_width - picture_width, and the boundary is set to picture_width. figure 41-4. picture-in-picture mode support channel locking: software can program a channel to keep the ahb master interface by locking the arbitration for the master bus interface for the duration of a dmac transfer, buffer, or chunk.
979 6438fCatarmC21-jun-10 at91sam9g45 bus locking: software can program a channel to maintain control of the amba bus by asserting hmastlock for the duration of a dmac transfer, buffer, or transaction (single or chunk). channel locking is asserted for the duration of bus locking at a minimum. 41.4.2 memory peripherals figure 41-3 on page 977 shows the dmac transfer hierarchy of the dmac for a memory periph- eral. there is no handshaking interface with the dmac, and therefore the memory peripheral can never be a flow controller. once the channel is enabled, the transfer proceeds immediately without waiting for a transaction request. the alternative to not having a transaction-level hand- shaking interface is to allow the dmac to at tempt amba transfers to the peripheral once the channel is enabled. if the peripheral slave cannot accept these amba transfers, it inserts wait states onto the bus until it is ready; it is not recommended that more than 16 wait states be inserted onto the bus. by using the handshaking interface, the peripheral can signal to the dmac that it is ready to transmit/receive dat a, and then the dmac can access the peripheral without the peripheral inserting wait states onto the bus. 41.4.3 handshaking interface handshaking interfaces are used at the transaction level to control the flow of single or chunk transfers. the operation of the handshaking interface is different and depends on whether the peripheral or the dmac is the flow controller. the peripheral uses the handshaking interface to in dicate to the dmac that it is ready to trans- fer/accept data over the amba bus. a non-memory peripheral can request a dmac transfer through the dmac using one of two handshaking interfaces: ? hardware handshaking ? software handshaking software selects between the hardware or software handshaking interface on a per-channel basis. software handshaking is accomplished through memory-mapped registers, while hard- ware handshaking is accomplished usin g a dedicated handshaking interface. 41.4.3.1 software handshaking when the slave peripheral requires the dmac to perform a dmac transaction, it communicates this request by sending an interrupt to the cpu or interrupt controller. the interrupt service routine then uses the software registers to initiate and control a dmac transaction. these software registers are used to implement the software handshaking interface. the src_h2sel/dst_h2sel bit in the dmac_cfgx channel c onfiguration register must be set to zero to enable software handshaking. when the peripheral is not the flow controller, then the last transaction register dmac_last is not used, and the values in these registers are ignored. 41.4.3.2 chunk transactions writing a 1 to the dmac_creq[2x] register starts a source chunk transaction request, where x is the channel number. writing a 1 to the dmac_creq[2x+1] register starts a destination chunk transfer request, where x is the channel number. upon completion of the chunk transaction, the hardware clears the dmac_creq[ 2x ] or dmac_creq[2x+1].
980 6438fCatarmC21-jun-10 at91sam9g45 41.4.3.3 single transactions writing a 1 to the dmac_sreq[2x] register starts a source single transaction request, where x is the channel number. writing a 1 to the dmac_s req[2x+1] register starts a destination single transfer request, where x is the channel number. upon completion of the chunk transaction, the hardware clears the dmac_sreq[x] or dmac_sreq[2x+1]. software can poll the relev ant channel bit in the dmac_creq[2x]/dmac_creq[2x+1] and dmac_sreq[x]/dmac_sreq[2x+1] registers. when both are 0, then either the requested chunk or single transaction has completed. 41.4.4 dmac transfer types a dmac transfer may consist of single or multi-buffers transfers. on successive buffers of a multi-buffer transfer, the dmac_saddrx/dmac_daddrx registers in the dmac are repro- grammed using either of the following methods: ? buffer chaining using linked lists ? replay mode ? contiguous address between buffers on successive buffers of a multi-buffer transfer, the dmac_ctrlax and dmac_ctrlbx regis- ters in the dmac are re-programmed using either of the following methods: ? buffer chaining using linked lists ? replay mode when buffer chaining, using linked lists is the multi-buffer method of choice, and on successive buffers, the dmac_dscrx register in the dmac is re-programmed using the following method: ? buffer chaining using linked lists a buffer descriptor (lli) consists of foll owing registers, dmac_saddrx, dmac_daddrx, dmac_dscrx, dmac_ctrlax, dmac_ctrlb x.these registers, along with the dmac_cfgx register, are used by the dmac to set up and describe the buffer transfer. 41.4.4.1 multi-buffer transfers 41.4.4.2 buffer chaining using linked lists in this case, the dmac re-programs the channel registers prior to the start of each buffer by fetching the buffer descriptor for that buffer from system memory. this is known as an lli update. dmac buffer chaining is supported by using a descriptor pointer register (dmac_dscrx) that stores the address in memory of the next buffer descriptor. each buffer descriptor contains the corresponding buffer descriptor (dma c_saddrx, dmac_daddrx, dmac_dscrx, dmac_ctrlax dmac_ctrlbx). to set up buffer chaining, a sequence of linked lists must be programmed in memory. the dmac_saddrx, dmac_daddrx, dmac _dscrx, dmac_ctrlax and dmac_ctrlbx registers are fetched from system memory on an lli update. the u pdated content of the dmac_ctrlax register is written back to memory on buffer completion. figure 41-5 on page 981 shows how to use chained linked lists in memory to define multi-buffer transfers using buffer chaining.
981 6438fCatarmC21-jun-10 at91sam9g45 the linked list multi-buffer transfer is init iated by programming dmac_dscrx with dscrx(0) (lli(0) base address) and dmac_ctrlbx regist er with both src_dscr and dst_dscr set to 0. other fields and registers are ignored and overwritten when the descriptor is retrieved from memory. the last transfer descriptor must be written to memory with its next descriptor address set to 0. figure 41-5. multi buffer transfer using linked list system memory saddrx = dscrx(0) + 0x0 daddrx = dscrx(0) + 0x4 ctrlax = dscrx(0) + 0x8 ctrlbx = dscrx(0) + 0xc dscrx(1) = dscrx(0) + 0x10 saddrx = dscrx(1) + 0x0 daddrx = dscrx(1) + 0x4 ctrlbx = dscrx(1) + 0x8 ctrlbx = dscrx(1) + 0xc dscrx(2) = dscrx(1) + 0x10 dscrx(0) dscrx(2) (points to 0 if lli(1) is the last transfer descriptor dscrx(1) lli(0) lli(1)
982 6438fCatarmC21-jun-10 at91sam9g45 41.4.4.3 programming dmac for multiple buffer transfers notes: 1. usr means that the register field is manually programmed by the user. 2. cont means that address are contiguous. 3. rep means that the register field is updat ed with its previous value. if the transfer is the first one, then the user must ma nu- ally program the value. 4. channel stalled is true if the relevant btc interrupt is not masked. 5. lli means that the register field is updat ed with the content of the linked list item. 41.4.4.4 replay mode of channel registers during automatic replay mode, the channel registers are reloaded with their initial values at the completion of each buffer and the new values used for the new buffer. depending on the row number in table 41-2 on page 982 , some or all of the dmac_saddrx, dmac_daddrx, dmac_ctrlax and dmac_ctrlbx channel register s are reloaded from their initial value at the start of a buffer transfer. 41.4.4.5 contiguous address between buffers in this case, the address between successive buffers is selected to be a continuation from the end of the previous buffer. enabling the source or destination address to be contiguous between table 41-2. multiple buffers transfer management table transfer type auto src_rep dst_rep src_dscr dst_dscr btsize saddr daddr other fields 1) single buffer or last buffer of a multiple buffer transfer 0 C C 1 1 usr usr usr usr 2) multi buffer transfer with contiguous daddr 0 C 0 0 1 lli lli cont lli 3) multi buffer transfer with contiguous saddr 0 0 C 1 0 lli cont lli lli 4) multi buffer transfer with lli support 0 C C 0 0 lli lli lli lli 5) multi buffer transfer with daddr reloaded 0 C 1 0 1 lli lli rep lli 6) multi buffer transfer with saddr reloaded 0 1 C 1 0 lli rep lli lli 7) multi buffer transfer with btsize reloaded and contiguous daddr 1 C 0 0 1 rep lli cont lli 8) multi buffer transfer with btsize reloaded and contiguous saddr 1 0 C 1 0 rep cont lli lli 9) automatic mode channel is stalling btsize is reloaded 1 0 0 1 1 rep cont cont rep 10) automatic mode btsize, saddr and daddr reloaded 1 1 1 1 1 rep rep rep rep 11) automatic mode btsize, saddr reloaded and daddr contiguous 11 0 1 1reprepcontrep
983 6438fCatarmC21-jun-10 at91sam9g45 buffers is a function of dmac_ctr lax.src_dscr, dmac_cfgx.src_rep, dmac_ctrlax.dst_dscr and dmac_cfgx.dst_rep registers. 41.4.4.6 suspension of transfers between buffers at the end of every buffer transfer, an end of buffer interrupt is asserted if: ? the channel buffer interrupt is unmasked, dmac_ebcimr.btc[n] = 1, where n is the channel number. note: the buffer complete interrupt is generated at the completion of the buffer transfer to the destination. at the end of a chain of multiple buffers, an end of linked list interrupt is asserted if: ? the channel end of chained buffer interrupt is unmasked, dmac_ebcimr.cbtc[n] = 1, when n is the channel number. 41.4.4.7 ending multi-buffer transfers all multi-buffer transfers must end as shown in row 1 of table 41-2 on page 982 . at the end of every buffer transfer, the dmac samples the row number, and if the dmac is in row 1 state, then the previous buffer transferred was the last buffer and the dmac transfer is terminated. for rows 9, 10 and 11 of table 41-2 on page 982 , (dmac_dscrx = 0 and dmac_ctrlbx.auto is set), mult i-buffer dmac transfers continue until the automatic mode is disabled by writing a 1 in dm ac_ctrlbx.auto bit. this bit should be programmed to zero in the end of buffer interrupt service routine that services the next-to-last buffer transfer. this puts the dmac into row 1 state. for rows 2, 3, 4, 5, and 6 (dmac_crtlbx.auto cleared) the user must setup the last buffer descriptor in memory such that both lli.dmac_ctrlbx.src_dscr and lli.dmac_ctrlbx.dst_dscr are one and lli.dmac_dscrx is set to 0.
984 6438fCatarmC21-jun-10 at91sam9g45 41.4.5 programming a channel four registers, the dmac_dscrx, the dmac_ctrlax, the dmac_ctrlbx and dmac_cfgx, need to be programmed to set up whether single or multi-buffer transfers take place, and which type of multi-buffer transfer is used. the different transfer types are shown in table 41-2 on page 982 . the btsize, saddr and daddr columns in dicate where the values of dmac_sarx, dmac_darx, dmac_ctlx, and dmac_llpx are obtained for the next buffer transfer when multi-buffer dmac transfers are enabled. 41.4.5.1 programming examples 41.4.5.2 single-buffer transfer (row 1) 1. read the channel handler status regist er dmac_chsr.enable field to choose a free (disabled) channel. 2. clear any pending interrupts on the channel from the previous dmac transfer by read- ing the interrupt status register, dmac_ebcisr. 3. program the following channel registers: a. write the starting source address in the dmac_saddrx register for channel x. b. write the starting destination address in the dmac_daddrx register for channel x. c. program dmac_ctrlax, dmac_ctrlbx and dmac_cfgx according to row 1 as shown in table 41-2 on page 982 . program the dmac_ctrlbx register with both dst_dscr and src_dscr fields se t to one and auto field set to 0. d. write the control information for the dmac transfer in the dmac_ctrlax and dmac_ctrlbx registers for channel x. for example, in the register, you can pro- gram the following: C i. set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the fc of the dmac_ctrlbx register. C ii. set up the transfer characteristics, such as: C transfer width for the source in the src_width field. C transfer width for the desti nation in the dst_width field. C source ahb master interface layer in the sif field where source resides. C destination ahb master interface layer in the dif field where destination resides. C incrementing/decrementing or fixed address for source in src_inc field. C incrementing/decrementing or fixed address for destination in dst_inc field. e. write the channel configuration information into the dmac_cfgx register for chan- nel x. C i. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires programming the src_h2sel/dst_h2sel bits, respectively. writing a 1 activates the hardware handshaking interface to handle source/destination requests. writing a 0 activates the software handshaking interface to handle source/destination requests.
985 6438fCatarmC21-jun-10 at91sam9g45 C ii. if the hardware handshaking interface is activated for the source or destination peripheral, assign a handshaking interface to the source and destination peripheral. this requires programming the src_per and dst_per bits, respectively. f. if source picture-in-picture mode is enabled (dmac_ctrlbx.src_pip is enabled), program the dmac_spipx register for channel x. g. if destination picture-in-picture mode is enabled (dmac_ctrlbx.dst_pip is enabled), program the dmac_dpipx register for channel x. 4. after the dmac selected channel has been programmed, enable the channel by writing a 1 to the dmac_cher.enable[n] bit, where n is the channel number. make sure that bit 0 of dmac_en.enable register is enabled. 5. source and destination request single and chunk dmac transactions to transfer the buffer of data (assuming non-memory peripherals). the dmac acknowledges at the completion of every transaction (chunk and single) in the buffer and carry out the buffer transfer. 6. once the transfer completes, hardware sets the interrupts and disables the channel. at this time you can either respond to the buffer complete or transfer complete interrupts, or poll for the channel handler status regist er (dmac_chsr.enable[n]) bit until it is cleared by hardware, to detect when the transfer is complete. 41.4.5.3 multi-buffer transfer with linked list for source and linked list for destination (row 4) 1. read the channel enable register to choose a free (disabled) channel. 2. set up the chain of linked list items (otherwise known as buffer descriptors) in mem- ory. write the control information in the lli.dmac_ctrlax and lli.dmac_ctrlbx registers location of the buffer descriptor for each lli in memory (see figure 41-6 on page 987 ) for channel x. for example, in the register, you can program the following: a. set up the transfer type (memory or non-memory peripheral for source and desti- nation) and flow control device by programming the fc of the dmac_ctrlbx register. b. set up the transfer characteristics, such as: C i. transfer width for the source in the src_width field. C ii. transfer width for the dest ination in the dst_width field. C iii. source ahb master in terface layer in the sif field where source resides. C iv. destination ahb master interface layer in the dif field where destination resides. C v. incrementing/decrementing or fixed address for source in src_incr field. C vi. incrementing/decrement ing or fixed address for destination dst_incr field. 3. write the channel configuration information into the dmac_cfgx register for channel x. a. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires pro- gramming the src_h2sel/dst_h2sel bits, respectively. writing a 1 activates the hardware handshaking interface to ha ndle source/destination requests for the specific channel. writing a 0 activates the software handshaking interface to han- dle source/destination requests. b. if the hardware handshaking interface is activated for the source or destination peripheral, assign the handshaking interface to the source and destination periph- eral. this requires programming the src_per and dst_per bits, respectively. 4. make sure that the lli.dmac_ctrlbx register locations of all lli entries in memory (except the last) are set as shown in row 4 of table 41-2 on page 982 . the
986 6438fCatarmC21-jun-10 at91sam9g45 lli.dmac_ctrlbx register of the last linked list item must be set as described in row 1 of table 41-2 . figure 41-5 on page 981 shows a linked list example with two list items. 5. make sure that the lli.dmac_dscrx register locations of all lli entries in memory (except the last) are non-zero and point to the base address of the next linked list item. 6. make sure that the lli.dmac_saddrx/lli. dmac_daddrx register locations of all lli entries in memory point to the start source/destination buffer address preceding that lli fetch. 7. make sure that the lli.dmac_ctrlax.done field of the lli.dmac_ctrlax register locations of all lli entries in memory are cleared. 8. if source picture-picture mode is enabled (dmac_ctrlbx.src_pip is enabled), pro- gram the dmac_spipx register for channel x. 9. if destination picture-in-picture is enabled (dmac_ctrlbx.dst_pip is enabled), pro- gram the dmac_dpipx register for channel x. 10. clear any pending interrupts on the channel from the previous dmac transfer by read- ing the status register: dmac_ebcisr. 11. program the dmac_ctrlbx, dmac_cfgx registers according to row 4 as shown in table 41-2 on page 982 . 12. program the dmac_dscrx register with dmac_dscrx(0), the pointer to the first linked list item. 13. finally, enable the channel by writing a 1 to the dmac_cher.enable[n] bit, where n is the channel number. the transfer is performed. 14. the dmac fetches the first lli from the location pointed to by dmac_dscrx(0). note: the lli.dmac_saddrx, lli. dmac_daddrx, lli.dmac_dscrx, lli.dmac_ctrlax and lli.dmac_ctrlbx registers are fetched. the dmac automatically reprograms the dmac_saddrx, dmac_daddrx, dmac_dscrx, dmac_ctrlbx and dmac_ctrlax chan- nel registers from the dmac_dscrx(0). 15. source and destination request single and chunk dmac transactions to transfer the buffer of data (assuming non-memory peripheral). the dmac acknowledges at the completion of every transaction (chunk and single) in the buffer and carry out the buffer transfer. 16. once the buffer of data is transferred, the dmac_ctrlax register is written out to sys- tem memory at the same location and on the same layer (dmac_dscrx.dscr_if) where it was originally fetched, that is, the location of the dmac_ctrlax register of the linked list item fetched prior to the start of the buffer transfer. only dmac_ctrlax register is written out because only the dmac_ctrlax.btsize and dmac_ctrlax.done bits have been updated by dmac hardware. additionally, the dmac_ctrlax.done bit is asserted when the buffer transfer has completed. note: do not poll the dmac_ctrlax.done bit in the dmac memory map. instead, poll the lli.dmac_ctrlax.done bit in the lli for that buffer. if the poll lli.dmac_ctrlax.done bit is asserted, then this buffer transfer has complet ed. this lli.dmac_ctrlax.done bit was cleared at the start of the transfer. 17. the dmac does not wait for the buffer interrupt to be cleared, but continues fetching the next lli from the memory location pointed to by current dmac_dscrx register and automatically reprograms the dmac_saddrx, dmac_daddrx, dmac_dscrx, dmac_ctrlax and dmac_ctrlbx channel registers. the dmac transfer continues until the dmac determines that the dmac_ctrlbx and dmac_dscrx registers at the end of a buffer transfer match described in row 1 of table 41-2 on page 982 . the dmac then knows that the previous buffer transferred was the last buffer in the dmac transfer. the dmac transfer might look like that shown in figure 41-6 on page 987 .
987 6438fCatarmC21-jun-10 at91sam9g45 figure 41-6. multi-buffer with linked list address for source and destination if the user needs to execute a dmac transfer where the source and destination address are contiguous but the amount of data to be transferred is greater than the maximum buffer size dmac_ctrlax.btsize, then this can be achieved using the type of multi-buffer transfer as shown in figure 41-7 on page 988 . saddr(2) saddr(1) saddr(0) daddr(2) daddr(1) daddr(0) buffer 2 buffer 1 buffer 0 buffer 0 buffer 1 buffer 2 address of source layer address of destination layer source buffers destination buffers
988 6438fCatarmC21-jun-10 at91sam9g45 figure 41-7. multi-buffer with linked address for source and destination buffers are contiguous the dmac transfer flow is shown in figure 41-8 on page 989 . saddr(2) saddr(1) saddr(0) daddr(2) daddr(1) daddr(0) buffer 2 buffer 1 buffer 0 buffer 0 buffer 1 buffer 2 address of source layer address of destination layer source buffers destination buffers saddr(3) buffer 2 daddr(3) buffer 2
989 6438fCatarmC21-jun-10 at91sam9g45 figure 41-8. dmac transfer flow for source and destination linked list address 41.4.5.4 multi-buffer transfer with source address auto-reloaded and destination address auto-reloaded (row 10) 1. read the channel enable register to choose an available (disabled) channel. 2. clear any pending interrupts on the channel from the previous dmac transfer by read- ing the interrupt status register. program the following channel registers: channel enabled by software lli fetch hardware reprograms saddrx, daddrx, ctrla/bx, dscrx dmac buffer transfer writeback of hdma_ctrlax register in system memory is hdma in row1 of hdma state machine table? channel disabled by hardware buffer complete interrupt generated here hdma transfer complete interrupt generated here yes no
990 6438fCatarmC21-jun-10 at91sam9g45 a. write the starting source address in the dmac_saddrx register for channel x. b. write the starting destination address in the dmac_daddrx register for channel x. c. program dmac_ctrlax, dmac_ctrlbx and dmac_cfgx according to row 10 as shown in table 41-2 on page 982 . program the dmac_dscrx register with 0. d. write the control information for the dmac transfer in the dmac_ctrlax and dmac_ctrlbx register for channel x. for example, in the register, you can pro- gram the following: C i. set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the fc of the dmac_ctrlbx register. C ii. set up the transfer characteristics, such as: C transfer width for the source in the src_width field. C transfer width for the desti nation in the dst_width field. C source ahb master interface layer in the sif field where source resides. C destination ahb master interface layer in the dif field where destination resides. C incrementing/decrementing or fixed address for source in src_incr field. C incrementing/decrementing or fixed address for destination in dst_incr field. e. if source picture-in-picture mode is enabled (dmac_ctrlbx.spip is enabled), program the dmac_spipx register for channel x. f. if destination picture-in-picture is enabled (dmac_ctrlbx.dpip), program the dmac_dpipx register for channel x. g. write the channel configuration information into the dmac_cfgx register for chan- nel x. ensure that the relo ad bits, dmac_cfgx.src_rep, dmac_cfgx.dst_rep and dmac_ctrlbx.auto are enabled. C i. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires programming the src_h2sel/dst_h2sel bits, respectively. writing a 1 activates the hardware handshaking interface to ha ndle source/destination requests for the specific channel. writing a 0 activates the software handshaking interface to handle source/destination requests. C ii. if the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripheral. this requires programming the src_per and dst_per bits, respectively. 3. after the dmac selected channel has been programmed, enable the channel by writing a 1 to the dmac_cher.enable[n] bit where is the channel number. make sure that bit 0 of the dmac_en register is enabled. 4. source and destination request single and chunk dmac transactions to transfer the buffer of data (assuming non-memory peripherals). the dmac acknowledges on com- pletion of each chunk/single transaction and carry out the buffer transfer. 5. when the buffer transfer has completed, the dmac reloads the dmac_saddrx, dmac_daddrx and dmac_ctrlax registers. hardware sets the buffer complete interrupt. the dmac then samples the row number as shown in table 41-2 on page 982 . if the dmac is in row 1, then the dmac transfer has completed. hardware sets the transfer complete interrupt and disables the channel. so you can either respond to the buffer complete or chained buffer transfer complete interrupts, or poll for the
991 6438fCatarmC21-jun-10 at91sam9g45 channel enable in the channel status register (dmac_chsr.enable[n]) until it is disabled, to detect when the transfer is complete. if the dmac is not in row 1, the next step is performed. 6. the dmac transfer proceeds as follows: a. if interrupts is un-masked (dmac_ebcimr.btc[x] = 1, where x is the channel number) hardware sets the buffer complete interrupt when the buffer transfer has completed. it then stalls until the stalled[n] bit of dmac_chsr register is cleared by software, writing 1 to dmac_cher.keepon[n] bit where n is the channel number. if the next buffer is to be the last buffer in the dmac transfer, then the buffer complete isr (interrupt service routine) should clear the automatic mode bit in the dmac_ctrlbx.auto bit. this put the dmac into row 1 as shown in table 41-2 on page 982 . if the next buffer is not the last buffer in the dmac trans- fer, then the reload bits should rema in enabled to keep the dmac in row 4. b. if the buffer complete interrupt is mask ed (dmac_ebcimr.btc[x] = 1, where x is the channel number), then hardware does not stall until it detects a write to the buf- fer complete interrupt enable register dmac_ebcier register but starts the next buffer transfer immediately. in this case software must clear the automatic mode bit in the dmac_ctrlb to put the dmac into row 1 of table 41-2 on page 982 before the last buffer of the dmac transfer has completed. the transfer is similar to that shown in figure 41-9 on page 991 . the dmac transfer flow is shown in figure 41-10 on page 992 . figure 41-9. multi-buffer dmac transfer with source and destination address auto-reloaded address of source layer address of destination layer source buffers destination buffers blockn block2 block1 block0 saddr daddr
992 6438fCatarmC21-jun-10 at91sam9g45 figure 41-10. dmac transfer flow for source and destination address auto-reloaded 41.4.5.5 multi-buffer transfer with source address auto-reloaded and linked list destination address (row 6) 1. read the channel enable register to choose a free (disabled) channel. 2. set up the chain of linked list items (otherwise known as buffer descriptors) in memory. write the control information in the lli.dmac_ctrlax and dmac_ctrlbx registers location of the buffer descriptor for each lli in memory for channel x. for example, in the register you can program the following: a. set up the transfer type (memory or non-memory peripheral for source and desti- nation) and flow control peripheral by programming the fc of the dmac_ctrlbx register. b. set up the transfer characteristics, such as: C i. transfer width for the source in the src_width field. C ii. transfer width for the dest ination in the dst_width field. C iii. source ahb master in terface layer in the sif field where source resides. C iv. destination ahb master interface layer in the dif field where destination resides. C v. incrementing/decrementing or fixed address for source in src_incr field. C vi. incrementing/decrement ing or fixed address for destination dst_incr field. channel enabled by software buffer transfer replay mode for saddrx, daddrx, ctrlax, ctrlbx channel disabled by hardware buffer complete interrupt generated here hdma transfer complete interrupt generated here yes no yes stall until stalled is cleared by writing to keepon field ebcimr[x]=1? no is hdma in row1 of hdma state machine table?
993 6438fCatarmC21-jun-10 at91sam9g45 3. write the starting source address in the dmac_saddrx register for channel x. note: the values in the lli.dmac_saddrx register lo cations of each of the linked list items (llis) setup up in memory, although fetched during a lli fetch, are not used. 4. write the channel configuration information into the dmac_cfgx register for channel x. a. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires pro- gramming the src_h2sel/dst_h2sel bits, respectively. writing a 1 activates the hardware handshaking interface to ha ndle source/destination requests for the specific channel. writing a 0 activates the software handshaking interface source/destination requests. b. if the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripheral. this requires programming the src_per and dst_per bits, respectively. 5. make sure that the lli.dmac_ctrlbx register locations of all llis in memory (except the last) are set as shown in row 6 of table 41-2 on page 982 while the lli.dmac_ctrlbx register of the last linked list item must be set as described in row 1 of table 41-2 . figure 41-5 on page 981 shows a linked list example with two list items. 6. make sure that the lli.dmac_dscrx register locations of all llis in memory (except the last) are non-zero and point to the next linked list item. 7. make sure that the lli.dmac_daddrx register location of all llis in memory point to the start destination buffer address proceeding that lli fetch. 8. make sure that the lli.dmac_ctlx.done field of the lli.dmac_ctrla register locations of all llis in memory is cleared. 9. if source picture-in-picture is enabled (dmac_ctrlbx.spip is enabled), program the dmac_spipx register for channel x. 10. if destination picture-in-p icture is enabled (dmac_ctrl bx.dpip is enabled), program the dmac_dpipx register for channel x. 11. clear any pending interrupts on the channel from the previous dmac transfer by read- ing to the dmac_ebcisr register. 12. program the dmac_ctlx, dmac_cfgx registers according to row 6 as shown in table 41-2 on page 982 . 13. program the dmac_dscrx register with dmac_dscrx(0), the pointer to the first linked list item. 14. finally, enable the channel by writing a 1 to the dmac_cher.enable[n] bit where n is the channel number. the transfer is performed. make sure that bit 0 of the dmac_en register is enabled. 15. the dmac fetches the first lli from the location pointed to by dmac_dscrx(0). note: the lli.dmac_saddrx, lli.dmac_daddrx , lli. dmac_llpx lli.dmac_ctrlax and lli.dmac_ctrlbx registers are fetched. the ll i.dmac_saddrx register although fetched is not used. 16. source and destination request single and chunk dmac transactions to transfer the buffer of data (assuming non-memory peripherals). dmac acknowledges at the com- pletion of every transaction (chunk and single) in the buffer and carry out the buffer transfer. 17. the dmac_ctrlax register is written out to system memory. the dmac_ctrlax register is written out to the same location on the same layer (dmac_dscrx.dscr_if) where it was origina lly fetched, that is the location of the dmac_ctrlax register of the linked list item fetched prior to the start of the buffer
994 6438fCatarmC21-jun-10 at91sam9g45 transfer. only dmac_ctrlax register is written out, because only the dmac_ctrlax.btsize and dmac_ctrlax.done fields have been updated by hardware within the dmac. the lli.dmac_ctrlax.done bit is asserted to indicate buffer completion therefore, software can poll the lli.dmac_ctrlax.done field of the dmac_ctrlax register in the lli to ascertain when a buffer transfer has completed. note: do not poll the dmac_ctrlax.done bit in the dmac memory map. instead poll the lli.dmac_ctrlax.done bit in the lli for that buffer. if the polled lli.dmac_ctrlax.done bit is asserted, then this buffer transfer has completed. this lli.dmac_ctrla.done bit was cleared at the start of the transfer. 18. the dmac reloads the dmac_saddrx register from the initial value. hardware sets the buffer complete interrupt. the dmac samples the row number as shown in table 41-2 on page 982 . if the dmac is in row 1, then the dmac transfer has completed. hardware sets the transfer complete interrupt and disables the channel. you can either respond to the buffer complete or chained buffer transfer complete interrupts, or poll for the channel enable (dmac_chsr.enable) bit until it is cleared by hardware, to detect when the transfer is complete. if the dmac is not in row 1 as shown in table 41- 2 on page 982 , the following step is performed. 19. the dmac fetches the next lli from memory location pointed to by the current dmac_dscrx register, and automatically reprograms the dmac_daddrx, dmac_ctrlax, dmac_ctrlbx and dmac_dscrx channel registers. note that the dmac_saddrx is not re-programmed as the reloaded value is used for the next dmac buffer transfer. if the next buffer is the last buffer of the dmac transfer then the dmac_ctrlbx and dmac_dscrx registers just fetched from the lli should match row 1 of table 41-2 on page 982 . the dmac transfer might look like that shown in fig- ure 41-11 on page 994 . figure 41-11. multi-buffer dmac transfer with source address auto-reloaded and linked list destination address the dmac transfer flow is shown in figure 41-12 on page 995 . address of source layer address of destination layer source buffers destination buffers saddr buffer0 buffer1 buffer2 buffern daddr(n) daddr(1) daddr(0) daddr(2)
995 6438fCatarmC21-jun-10 at91sam9g45 figure 41-12. dmac transfer flow for replay mode at source and linked list destination address 41.4.5.6 multi-buffer transfer with source address auto-reloaded and contiguous destination address (row 11) 1. read the channel enable register to choose a free (disabled) channel. 2. clear any pending interrupts on the channel from the previous dmac transfer by read- ing to the interrupt status register. 3. program the following channel registers: a. write the starting source address in the dmac_saddrx register for channel x. b. write the starting destination address in the dmac_daddrx register for channel x. c. program dmac_ctrlax, dmac_ctrlbx and dmac_cfgx according to row 11 as shown in table 41-2 on page 982 . program the dmac_dscrx register with 0. dmac_ctrlbx.auto field is set to 1 to enable automatic mode support. d. write the control information for the dmac transfer in the dmac_ctrlbx and dmac_ctrlax register for channel x. for example, in this register, you can pro- gram the following: C i. set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the fc of the dmac_ctrlbx register. channel enabled by software lli fetch yes no hardware reprograms daddrx, ctrlax, ctrlbx, dscrx dma buffer transfer writeback of control status information in lli reload saddrx buffer complete interrupt generated here hdma transfer complete interrupt generated here channel disabled by hardware is hdma in row1 of hdma state machine table?
996 6438fCatarmC21-jun-10 at91sam9g45 C ii. set up the transfer characteristics, such as: C transfer width for the source in the src_width field. C transfer width for the desti nation in the dst_width field. C source ahb master interface layer in the sif field where source resides. C destination ahb master interface master layer in the dif field where destination resides. C incrementing/decrementing or fixed address for source in src_incr field. C incrementing/decrementing or fixed address for destination in dst_incr field. e. if source picture-in-picture is enabled (dmac_ctrlbx.spip is enabled), program the dmac_spipx register for channel x. f. if destination picture-in-picture is enabled (dmac_ctrlbx.dpip), program the dmac_dpipx register for channel x. g. write the channel configuration information into the dmac_cfgx register for chan- nel x. C i. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires programming the src_h2sel/dst_h2sel bits, respectively. writing a 1 activates the hardware handshaking interface to ha ndle source/destination requests for the specific channel. writing a 0 activates the software handshaking interface to handle source/destination requests. C ii. if the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripheral. this requires programming the src_per and dst_per bits, respectively. 4. after the dmac channel has been programmed, enable the channel by writing a 1 to the dmac_cher.enable[n] bit where n is the channel number. make sure that bit 0 of the dmac_en.enable register is enabled. 5. source and destination request single and chunk dmac transactions to transfer the buffer of data (assuming non-memory peripherals). the dmac acknowledges at the completion of every transaction (chunk and single) in the buffer and carries out the buf- fer transfer. 6. when the buffer transfer has completed, the dmac reloads the dmac_saddrx regis- ter. the dmac_daddrx register remains unchanged. hardware sets the buffer complete interrupt. the dmac then sa mples the row number as shown in table 41-2 on page 982 . if the dmac is in row 1, then the dmac transfer has completed. hard- ware sets the transfer complete interrupt and disables the channel. so you can either respond to the buffer complete or transfer complete interrupts, or poll for enable field in the channel status register (dmac_chsr.enable[n] bit) until it is cleared by hardware, to detect when the transfer is complete. if the dmac is not in row 1, the next step is performed. 7. the dmac transfer proceeds as follows: a. if the buffer complete interrupt is un-masked (dmac_ebcimr.btc[x] = 1, where x is the channel number) hardware sets the buffer complete interrupt when the buf- fer transfer has completed. it then stalls until stalled[n] bit of dmac_chsr is cleared by writing in the keepon[n] field of dmac_cher register where n is the channel number. if the next buffer is to be the last buffer in the dmac transfer, then the buffer complete isr (interrupt service routine) should clear the automatic mode bit, dmac_ctrlbx.auto. this puts the dmac into row 1 as shown in table 41- 2 on page 982 . if the next buffer is not the last buffer in the dmac transfer then the
997 6438fCatarmC21-jun-10 at91sam9g45 automatic transfer mode bit should remain enabled to keep the dmac in row 11 as shown in table 41-2 on page 982 . b. if the buffer complete interrupt is mask ed (dmac_ebcimr.btc[x] = 1, where x is the channel number) then hardware does not stall until it detects a write to the buf- fer transfer completed interrupt enable register but starts the next buffer transfer immediately. in this case software must clear the automatic mode bit, dmac_ctrlbx.auto, to put the device into row 1 of table 41-2 on page 982 before the last buffer of the dmac transfer has completed. the transfer is similar to that shown in figure 41-13 on page 997 . the dmac transfer flow is shown in figure 41-14 on page 998 . figure 41-13. multi-buffer transfer with source address auto-reloaded and contiguous destination address address of source layer address of destination layer source buffers destination buffers saddr buffer0 buffer1 buffer2 daddr(1) daddr(0) daddr(2)
998 6438fCatarmC21-jun-10 at91sam9g45 figure 41-14. dmac transfer replay mode is enabled for th e source and contiguous destination address 41.4.5.7 multi-buffer dmac transfer with linked list for source and contiguous destination address (row 2) 1. read the channel enable register to choose a free (disabled) channel. 2. set up the linked list in memory. wr ite the control information in the lli.dmac_ctrlax and lli.dmac_ctrlbx register location of the buffer descriptor for each lli in memory for channel x. for example, in the register, you can program the following: a. set up the transfer type (memory or non-memory peripheral for source and desti- nation) and flow control device by programming the fc of the dmac_ctrlbx register. b. set up the transfer characteristics, such as: C i. transfer width for the source in the src_width field. C ii. transfer width for the dest ination in the dst_width field. C iii. source ahb master in terface layer in the sif field where source resides. C iv. destination ahb master interface layer in the dif field where destination resides. channel enabled by software buffer transfer replay mode for saddrx, contiguous mode for daddrx ctrlax, ctrlbx channel disabled by hardware buffer complete interrupt generated here buffer transfer complete interrupt generated here yes no no yes stall until stalled field is cleared by software writing keepon field dma_ebcimr[x]=1? is hdma in row1of hdma state machine table?
999 6438fCatarmC21-jun-10 at91sam9g45 C v. incrementing/decrementing or fixed address for source in src_incr field. C vi. incrementing/decrement ing or fixed address for destination dst_incr field. 3. write the starting destination address in the dmac_daddrx register for channel x. note: the values in the lli.dmac_daddrx register location of each linked list item (lli) in memory, although fetched during an lli fetch, are not used. 4. write the channel configuration information into the dmac_cfgx register for channel x. a. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires pro- gramming the src_h2sel/dst_h2sel bits, respectively. writing a 1 activates the hardware handshaking interface to ha ndle source/destination requests for the specific channel. writing a 0 activates the software handshaking interface to han- dle source/destination requests. b. if the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripherals. this requires programming the src_per and dst_per bits, respectively. 5. make sure that all lli.dmac_ctrlbx register locations of the lli (except the last) are set as shown in row 2 of table 41-2 on page 982 , while the lli.dmac_ctrlbx regis- ter of the last linked list item must be set as described in row 1 of table 41-2 . figure 41-5 on page 981 shows a linked list example with two list items. 6. make sure that the lli.dmac_dscrx register locations of all llis in memory (except the last) are non-zero and point to the next linked list item. 7. make sure that the lli.dmac_saddrx register location of all llis in memory point to the start source buffer address proceeding that lli fetch. 8. make sure that the lli.dmac_ctrlax.done field of the lli.dmac_ctrlax register locations of all llis in memory is cleared. 9. if source picture-in-picture is enabled (dmac_ctrlbx.spip is enabled), program the dmac_spipx register for channel x. 10. if destination picture-in-p icture is enabled (dmac_ctrl bx.dpip is enabled), program the dmac_dpipx register for channel x. 11. clear any pending interrupts on the channel from the previous dmac transfer by read- ing the interrupt status register. 12. program the dmac_ctrlax, dmac_ctrlbx and dmac_cfgx registers according to row 2 as shown in table 41-2 on page 982 13. program the dmac_dscrx register with dmac_dscrx(0), the pointer to the first linked list item. 14. finally, enable the channel by writing a 1 to the dmac_cher.enable[n] bit. the transfer is performed. make sure that bit 0 of the dmac_en register is enabled. 15. the dmac fetches the first lli from the location pointed to by dmac_dscrx(0). note: the lli.dmac_saddrx, lli.dmac_daddrx , lli.dmac_dscrx and lli.dmac_ctrla/bx registers are fetched. the lli.dmac_daddrx regist er location of the lli although fetched is not used. the dmac_daddrx register in the dmac remains unchanged. 16. source and destination requests single and chunk dmac transactions to transfer the buffer of data (assuming non-memory peripherals). the dmac acknowledges at the completion of every transaction (chunk and single) in the buffer and carry out the buffer transfer 17. once the buffer of data is transferred, the dmac_ctrlax register is written out to sys- tem memory at the same location and on the same layer (dmac_dscrx.dscr_if) where it was originally fetched, that is, the location of the dmac_ctrlax register of
1000 6438fCatarmC21-jun-10 at91sam9g45 the linked list item fetched prior to the start of the buffer transfer. only dmac_ctrlax register is written out because only the dmac_ctrlax.btsize and dmac_ctrlax.done fields have been updated by dmac hardware. additionally, the dmac_ctrlax.done bit is asserted when the buffer transfer has completed. note: do not poll the dmac_ctrlax.done bit in the dmac memory map. instead, poll the lli.dmac_ctrlax.done bit in the lli for that buffer. if the poll lli.dmac_ctrlax.done bit is asserted, then this buffer transfer has complet ed. this lli.dmac_ctrlax.done bit was cleared at the start of the transfer. 18. the dmac does not wait for the buffer interrupt to be cleared, but continues and fetches the next lli from the memory location pointed to by current dmac_dscrx register and automatically reprograms the dmac_saddrx, dmac_ctrlax, dmac_ctrlbx and dmac_dscrx channel registers. the dmac_daddrx register is left unchanged. the dmac transfer continues until the dmac samples the dmac_ctrlax, dmac_ctrlbx and dmac_dscrx registers at the end of a buffer transfer match that described in row 1 of table 41-2 on page 982 . the dmac then knows that the previous buffer transferred was the last buffer in the dmac transfer. the dmac transfer might look like that shown in figure 41-15 on page 1000 note that the desti- nation address is decrementing. figure 41-15. dmac transfer with linked list source address and contiguous destination address the dmac transfer flow is shown in figure 41-16 on page 1001 . saddr(2) saddr(1) saddr(0) daddr(2) daddr(1) daddr(0) buffer 2 buffer 1 buffer 0 buffer 0 buffer 1 buffer 2 address of source layer address of destination layer source buffers destination buffers
1001 6438fCatarmC21-jun-10 at91sam9g45 figure 41-16. dmac transfer flow for linked list source address and contiguous destination address 41.4.6 disabling a channel prior to transfer completion under normal operation, software enables a ch annel by writing a 1 to the channel handler enable register, dmac_cher.enable[n], and hardware disables a channel on transfer com- pletion by clearing the dmac_chsr.enable[n] register bit. the recommended way for software to disable a channel without losing data is to use the sus- pend[n] bit in conjunction with the empty[n] bit in the channel handler status register. channel enabled by software lli fetch hardware reprograms saddrx, ctrlax,ctrlbx, dscrx hdma buffer transfer writeback of control information of lli is hdma in row 1 ? channel disabled by hardware buffer complete interrupt generated here hdma transfer complete interrupt generated here yes no
1002 6438fCatarmC21-jun-10 at91sam9g45 1. if software wishes to disable a channel n prior to the dmac transfer completion, then it can set the dmac_cher.suspend[n] bit to te ll the dmac to halt all transfers from the source peripheral. therefore, the channel fifo receives no new data. 2. software can now poll the dmac_chsr.empty[n] bit until it indicates that the channel n fifo is empty, where n is the channel number. 3. the dmac_cher.enable[n] bit can then be cleared by software once the channel n fifo is empty, where n is the channel number. when dmac_ctrlax.src_width is less than dmac_ctrlax.dst_width and the dmac_chsrx.suspend[n] bit is high, the dm ac_chsrx.empty[n] is asserted once the contents of the fifo do not permit a single word of dmac_ctrlax.dst_width to be formed. however, there may still be data in the channel fifo but not enough to form a single transfer of dmac_ctlx.dst_width width. in th is configuration, once the channel is disabled, the remain- ing data in the channel fifo are not transferred to the destination peripheral. it is permitted to remove the channel from the suspension state by writing a 1 to the dmac_cher.resume[n] field register. the dmac transfer completes in the normal manner. n defines the channel number. note: if a channel is disabled by software, an active single or chunk transaction is not guaranteed to receive an acknowledgement. 41.4.6.1 abnormal transfer termination a dmac transfer may be terminated abruptly by so ftware by clearing the channel enable bit, dmac_chdr.enable[n] where n is the channel number. this does not mean that the channel is disabled immediately after the dmac_chsr.enable[n] bit is cleared over the apb inter- face. consider this as a request to disabl e the channel. the dmac_chsr.enable[n] must be polled and then it must be confirmed that the channel is disabled by reading back 0. software may terminate all channels abruptly by clearing the global enable bit in the dmac con- figuration register (dmac_en.enable bit). agai n, this does not mean that all channels are disabled immediately after the dmac_en.enable is cleared over the apb slave interface. consider this as a request to disable all c hannels. the dmac_chsr.enable must be polled and then it must be confirmed that all channels are disabled by reading back 0. note: if the channel enable bit is cleared while there is data in the channel fifo, this data is not sent to the destination peripheral and is not present when the channel is re-enabled. for read sensitive source peripherals, such as a source fifo, this data is therefore lost. when the source is not a read sensitive device (i.e., memory), disabling a channel without waiting for the channel fifo to empty may be acceptable as the data is available from the source peripheral upon request and is not lost. note: if a channel is disabled by software, an active single or chunk transaction is not guaranteed to receive an acknowledgement. 41.5 dmac software requirements ? there must not be any write operation to channel registers in an active channel after the channel enable is made high. if any channel parameters must be reprogrammed, this can only be done after disabling the dmac channel. ? when destination peripheral is defined as the fl ow controller, source single transfer request are not serviced until destination peripheral has asserted its last transfer flag. ? when source peripheral is flow controller, destination single transfer request are not serviced until source peripheral has asserted its last transfer flag.
1003 6438fCatarmC21-jun-10 at91sam9g45 ? when destination peripheral is defined as the flow controller, if the destination width is smaller than the source width, then a data loss may occur, and the loss is equal to source single transfer size in bytes- dest ination single transfer size in bytes. ? when a memory to peripheral transfer occurs if the destination peripheral is flow controller, then a prefetch operation is performed. it means that data are extracted from memory before any request from the peripheral is generated. ? you must program the dmac_saddrx and dm ac_daddrx channel registers with a byte, half-word and word aligned address depending on the source width and destination width. ? after the software disables a channel by writing into the channel disable register, it must re- enable the channel only after it has polled a 0 in the corresponding channel enable status register. this is because the current ahb burst must terminate properly. ? if you program the btsize field in the dmac _ctrla, as zero, and the dmac is defined as the flow controller, then the channel is automatically disabled. ? when hardware handshaking interface protocol is fully implemented, a peripheral is expected to deassert any sreq or breq signals on receiv ing the ack signal irrespective of the request the ack was asserted in response to. ? multiple transfers involving the same peripheral must not be programmed and enabled on different channel, unless this peripheral inte grates several hardware handshaking interface. ? when a peripheral is flow controller, the targeted dmac channel must be enabled before the peripheral. if you do not ensure this the dmac channel might miss a last transfer flag, if the first dmac request is also the last transfer. ? when auto field is set to true, then the btsize field is automatically reloaded from its previous value. btsize must be initialized to a non zero value if the firs t transfer is initiated with auto field set to true even if lli mode is enabled because the lli fetch operation will not update this field.
1004 6438fCatarmC21-jun-10 at91sam9g45 41.6 dma controller (dmac) user interface note: 1. the addresses for the dmac registers shown here are for dma channel 0. this sequence of registers is repeated succes- sively for each dma channel located between 0x064 and 0x140 . table 41-3. register mapping offset register name access reset 0x000 dmac global configuration register dmac_gcfg read-write 0x10 0x004 dmac enable register dmac_en read-write 0x0 0x008 dmac software single request register dmac_sreq read-write 0x0 0x00c dmac software chunk transfer request register dmac_creq read-write 0x0 0x010 dmac software last transfer flag register dmac_last read-write 0x0 0x014 reserved C C C 0x018 dmac error, chained buffer transfer completed and buffer transfer completed interrupt enable register. dmac_ebcier write-only C 0x01c dmac error, chained buffer transfer completed and buffer transfer completed interrupt disable register. dmac_ebcidr write-only C 0x020 dmac error, chained buffer transfer completed and buffer transfer completed mask register. dmac_ebcimr read-only 0x0 0x024 dmac error, chained buffer transfer completed and buffer transfer completed status register. dmac_ebcisr read-only 0x0 0x028 dmac channel handler enable register dmac_cher write-only C 0x02c dmac channel handler disable register dmac_chdr write-only C 0x030 dmac channel handler status register dmac_chsr read-only 0x00ff0000 0x034 reserved C C C 0x038 reserved C C C 0x03c+ch_num*(0x28)+(0x0) dmac channel source address register dmac_saddr read-write 0x0 0x03c+ch_num*(0x28)+(0x4) dmac channel destinat ion address register dmac_daddr read-write 0x0 0x03c+ch_num*(0x28)+(0x8) dmac channel descript or address register dmac_dscr read-write 0x0 0x03c+ch_num*(0x28)+(0xc) dmac channel control a register dmac_ctrla read-write 0x0 0x03c+ch_num*(0x28)+(0x10) dmac channel control b register dmac_ctrlb read-write 0x0 0x03c+ch_num*(0x28)+(0x14) dmac channel confi guration register dmac_cfg read-write 0x01000000 0x03c+ch_num*(0x28)+(0x18) dmac channel source picture in picture configuration register dmac_spip read-write 0x0 0x03c+ch_num*(0x28)+(0x1c) dmac channel destination picture in picture configuration register dmac_dpip read-write 0x0 0x03c+ch_num*(0x28)+(0x20) reserved C C C 0x03c+ch_num*(0x28)+(0x24) reserved C C C 0x064 - 0x140 dmac channel 1 to 7 register (1) read-write 0x0 0x017c- 0x1fc reserved C C C
1005 6438fCatarmC21-jun-10 at91sam9g45 41.6.1 dmac global configuration register name: dmac_gcfg address: 0xffffec00 access: read-write reset: 0x00000010 note: bit fields 0, 1, 2, 3, have a default value of 0. this should not be changed. ? arb_cfg 0: fixed priority arbiter. 1: modified round robin arbiter. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCarb_cfgCCCC
1006 6438fCatarmC21-jun-10 at91sam9g45 41.6.2 dmac enable register name: dmac_en address: 0xffffec04 access: read-write reset: 0x00000000 ? enable 0: dma controller is disabled. 1: dma controller is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCenable
1007 6438fCatarmC21-jun-10 at91sam9g45 41.6.3 dmac software single request register name: dmac_sreq address: 0xffffec08 access: read-write reset: 0x00000000 ? dsreqx request a destination single transfer on channel i. ? ssreqx request a source single transfer on channel i. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 dsreq7 ssreq7 dsreq6 ssreq6 dsreq5 ssreq5 dsreq4 ssreq4 76543210 dsreq3 ssreq3 dsreq2 ssreq2 dsreq1 ssreq1 dsreq0 ssreq0
1008 6438fCatarmC21-jun-10 at91sam9g45 41.6.4 dmac software chunk transfer request register name: dmac_creq address: 0xffffec0c access: read-write reset: 0x00000000 ? dcreqx request a destination chunk transfer on channel i. ?screqx request a source chunk transfer on channel i. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 dcreq7 screq7 dcreq6 scre q6 dcreq5 screq5 dcreq4 screq4 76543210 dcreq3 screq3 dcreq2 scre q2 dcreq1 screq1 dcreq0 screq0
1009 6438fCatarmC21-jun-10 at91sam9g45 41.6.5 dmac software last transfer flag register name: dmac_last address: 0xffffec10 access: read-write reset: 0x00000000 ?dlastx writing one to dlastx prior to writing one to dsreqx or dcreqx indicates that this destination request is the last transfer of the buffer. ?slastx writing one to slastx prior to writing one to ssreqx or screqx indicates that this source request is the last transfer of the buffer. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 dlast7 slast7 dlast6 slast6 d last5 slast5 dlast4 slast4 76543210 dlast3 slast3 dlast2 slast2 d last1 slast1 dlast0 slast0
1010 6438fCatarmC21-jun-10 at91sam9g45 41.6.6 dmac error, buffer transfer and chained buffer transfer interrupt enable register name: dmac_ebcier address: 0xffffec18 access: write-only reset: 0x00000000 ? btc[7:0] buffer transfer completed interrupt enable register. set the relevant bit in the btc field to enable the interrupt for channel i. ? cbtc[7:0] chained buffer transfer completed interrupt enable register. set the relevant bit in the cbtc field to enable the interrupt for channel i. ? err[7:0] access error interrupt enable register. set the relevant bi t in the err field to enable the interrupt for channel i. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 err7 err6 err5 err4 err3 err2 err1 err0 15 14 13 12 11 10 9 8 cbtc7 cbtc6 cbtc5 cbtc4 cbtc3 cbtc2 cbtc1 cbtc0 76543210 btc7 btc6 btc5 btc4 btc3 btc2 btc1 btc0
1011 6438fCatarmC21-jun-10 at91sam9g45 41.6.7 dmac error, buffer transfer and chained buffer transfer interrupt disable register name: dmac_ebcidr address: 0xffffec1c access: write-only reset: 0x00000000 ? btc[7:0] buffer transfer completed disable interrupt register. when set, a bit of the btc field disables the interrupt from the rele- vant dmac channel. ? cbtc[7:0] chained buffer transfer completed disable register. when set, a bit of the cbtc field disables the interrupt from the rele- vant dmac channel. ? err[7:0] access error interrupt disable register. when set, a bit of t he err field disables the interrupt from the relevant dmac channel. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 err7 err6 err5 err4 err3 err2 err1 err0 15 14 13 12 11 10 9 8 cbtc7 cbtc6 cbtc5 cbtc4 cbtc3 cbtc2 cbtc1 cbtc0 76543210 btc7 btc6 btc5 btc4 btc3 btc2 btc1 btc0
1012 6438fCatarmC21-jun-10 at91sam9g45 41.6.8 dmac error, buffer transfer and chained buffer transfer interrupt mask register name: dmac_ebcimr address: 0xffffec20 access: read-only reset: 0x00000000 ? btc[7:0] 0: buffer transfer completed interrupt is disabled for channel i. 1: buffer transfer completed interrupt is enabled for channel i. ? cbtc[7:0] 0: chained buffer transfer interrupt is disabled for channel i. 1: chained buffer transfer interrupt is enabled for channel i. ? err[7:0] 0: transfer error interrupt is disabled for channel i. 1: transfer error interrupt is enabled for channel i. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 err7 err6 err5 err4 err3 err2 err1 err0 15 14 13 12 11 10 9 8 cbtc7 cbtc6 cbtc5 cbtc4 cbtc3 cbtc2 cbtc1 cbtc0 76543210 btc7 btc6 btc5 btc4 btc3 btc2 btc1 btc0
1013 6438fCatarmC21-jun-10 at91sam9g45 41.6.9 dmac error, buffer transfer and chained buffer transfer status register name: dmac_ebcisr address: 0xffffec24 access: read-only reset: 0x00000000 ? btc[7:0] when btc[ i ] is set, channel i buffer transfer has terminated. ? cbtc[7:0] when cbtc[ i ] is set, channel i chained buffer has terminated. lli fetch operation is disabled. ? err[7:0] when err[ i ] is set, channel i has detected an ahb read or write error access. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 err7 err6 err5 err4 err3 err2 err1 err0 15 14 13 12 11 10 9 8 cbtc7 cbtc6 cbtc5 cbtc4 cbtc3 cbtc2 cbtc1 cbtc0 76543210 btc7 btc6 btc5 btc4 btc3 btc2 btc1 btc0
1014 6438fCatarmC21-jun-10 at91sam9g45 41.6.10 dmac channel handler enable register name: dmac_cher address: 0xffffec28 access: write-only reset: 0x00000000 ? ena[7:0] when set, a bit of the ena field enables the relevant channel. ? susp[7:0] when set, a bit of the suspfield freezes the relevant channel and its current context. ? keep[7:0] when set, a bit of the keep fi eld resumes the current channel from an automatic stall state. 31 30 29 28 27 26 25 24 keep7 keep6 keep5 keep4 keep3 keep2 keep1 keep0 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 susp7 susp6 susp5 susp4 susp3 susp2 susp1 susp0 76543210 ena7 ena6 ena5 ena4 ena3 ena2 ena1 ena0
1015 6438fCatarmC21-jun-10 at91sam9g45 41.6.11 dmac channel handler disable register name: dmac_chdr address: 0xffffec2c access: write-only reset: 0x00000000 ? dis[7:0] write one to this field to disable the relevant dmac channel. the content of the fifo is lost and the current ahb access is terminated. software must poll dis[7:0] field in the dmac_chsr register to be sure that the channel is disabled. ? res[7:0] write one to this field to resume the channel transfer restoring its context. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 res7 res6 res5 res4 res3 res2 res1 res0 76543210 dis7 dis6 dis5 dis4 dis3 dis2 dis1 dis0
1016 6438fCatarmC21-jun-10 at91sam9g45 41.6.12 dmac channel handler status register name: dmac_chsr address: 0xffffec30 access: read-only reset: 0x00ff0000 ? ena[7:0] a one in any position of this field indicates that the relevant channel is enabled. ? susp[7:0] a one in any position of this field indicates that the channel transfer is suspended. ? empt[7:0] a one in any position of this field indicates that the relevant channel is empty. ? stal[7:0] a one in any position of this field indica tes that the relevant channel is stalling. 31 30 29 28 27 26 25 24 stal7 stal6 stal5 stal4 stal3 stal2 stal1 stal0 23 22 21 20 19 18 17 16 empt7 empt6 empt5 empt4 empt3 empt2 empt1 empt0 15 14 13 12 11 10 9 8 susp7 susp6 susp5 susp4 susp3 susp2 susp1 susp0 76543210 ena7 ena6 ena5 ena4 ena3 ena2 ena1 ena0
1017 6438fCatarmC21-jun-10 at91sam9g45 41.6.13 dmac channel x [x = 0..7] source address register name: dmac_saddrx [x = 0..7] addresses: 0xffffec3c [0], 0xffffec64 [1], 0xffffec8c [2], 0xffffecb4 [3], 0xffffecdc [4], 0xffffed04 [5], 0xffffed2c [6], 0xffffed54 [7] access: read-write reset: 0x00000000 ? saddrx channel x source address. this register must be aligned with the source transfer width. 41.6.14 dmac channel x [x = 0..7] destination address register name: dmac_daddrx [x = 0..7] addresses: 0xffffec40 [0], 0xffffec68 [1], 0xffffec90 [2], 0xffffecb8 [3], 0xffffece0 [4], 0xffffed08 [5], 0xffffed30 [6], 0xffffed58 [7] access: read-write reset: 0x00000000 ? daddrx channel x destination address. this register must be aligned with the destination transfer width. 31 30 29 28 27 26 25 24 saddrx 23 22 21 20 19 18 17 16 saddrx 15 14 13 12 11 10 9 8 saddrx 76543210 saddrx 31 30 29 28 27 26 25 24 daddrx 23 22 21 20 19 18 17 16 daddrx 15 14 13 12 11 10 9 8 daddrx 76543210 daddrx
1018 6438fCatarmC21-jun-10 at91sam9g45 41.6.15 dmac channel x [x = 0..7] descriptor address register name: dmac_dscrx [x = 0..7] addresses: 0xffffec44 [0], 0xffffec6c [1], 0xffffec94 [2], 0xffffecbc [3], 0xffffe ce4 [4], 0xffffed0[5] 0xffffed34 [6], 0xffffed5c [7] access: read-write reset: 0x00000000 ?dscrx_if 00: the buffer transfer descriptor is fetched via ahb-lite interface 0. 01: the buffer transfer descriptor is fetched via ahb-lite interface 1. 10: reserved. 11: reserved. ?dscrx buffer transfer descriptor address. this address is word aligned. 31 30 29 28 27 26 25 24 dscrx 23 22 21 20 19 18 17 16 dscrx 15 14 13 12 11 10 9 8 dscrx 76543210 dscrx dscrx_if
1019 6438fCatarmC21-jun-10 at91sam9g45 41.6.16 dmac channel x [x = 0..7] control a register name: dmac_ctrlax [x = 0..7] addresses: 0xffffec48 [0], 0xffffec70 [1], 0xffffec98 [2], 0x ffffecc0 [3], 0xffffece8 [4], 0xffffed10 [5], 0xffffed38 [6], 0xffffed60 [7] access: read-write reset: 0x00000000 ?btsize buffer transfer size. the transfer size relates to the number of transfers to be performed, that is, for writes it refers to th e number of source width transfers to perform when dmac is flow controller. for reads, btsize refers to the number of transfers completed on the source interface. when this field is set to 0, the dmac module is automatically disabled when the relevant channel is enabled. ?scsize source chunk tr ansfer size. ? dcsize destination chunk transfer size. 31 30 29 28 27 26 25 24 done C dst_width C C src_width 23 22 21 20 19 18 17 16 C dcsize C scsize 15 14 13 12 11 10 9 8 btsize 76543210 btsize scsize value number of data transferred 000 1 001 4 010 8 011 16 100 32 101 64 110 128 111 256 dcsize number of data transferred 000 1 001 4 010 8
1020 6438fCatarmC21-jun-10 at91sam9g45 ?src_width ?dst_width ?done 0: the transfer is performed. 1: if sod field of dmac_cfg register is set to true, then the dmac is automatically disabled when an lli updates the con- tent of this register. the done field is written back to memory at the end of the transfer. 011 16 100 32 101 64 110 128 111 256 src_width single transfer size 00 byte 01 half-word 1x word dst_width single transfer size 00 byte 01 half-word 1x word dcsize number of data transferred
1021 6438fCatarmC21-jun-10 at91sam9g45 41.6.17 dmac channel x [x = 0..7] control b register name: dmac_ctrlbx [x = 0..7] addresses: 0xffffec4c [0], 0xffffec74 [1], 0xffffec9c [2], 0xffffecc4 [3], 0xffffecec [4], 0xffffed14 [5], 0xffffed3c [6], 0xffffed64 [7] access: read-write reset: 0x00000000 ? sif: source interface selection field 00: the source transfer is done via ahb-lite interface 0. 01: the source transfer is done via ahb-lite interface 1. 10: reserved. 11: reserved. ? dif: destination interface selection field 00: the destination transfer is done via ahb-lite interface 0. 01: the destination transfer is done via ahb-lite interface 1. 10: reserved. 11: reserved. ?src_pip 0: picture-in-picture mode is disabled. the source data area is contiguous. 1: picture-in-picture mode is enabled. when the source pip counter reaches the programmable boundary, the address is automatically increment of a user defined amount. ?dst_pip 0: picture-in-picture mode is disabled. the destination data area is contiguous. 1: picture-in-picture mode is enabled. when the destinati on pip counter reaches the programmable boundary the address is automatically incremented by a user-defined amount. ?src_dscr 0: source address is updated when the descriptor is fetched from the memory. 1: buffer descriptor fetch operation is disabled for the source. 31 30 29 28 27 26 25 24 auto ien dst_incr C C src_incr 23 22 21 20 19 18 17 16 fc dst_dscr C C C src_dscr 15 14 13 12 11 10 9 8 CC dst_pipCCCsrc_pip 76543210 CC dif CC sif
1022 6438fCatarmC21-jun-10 at91sam9g45 ? dst_dscr 0: destination address is updated when the descriptor is fetched from the memory. 1: buffer descriptor fetch operation is disabled for the destination. ?fc this field defines which device controls the size of the buffer transfer, also referred as to the flow controller. ?src_incr ? dst_incr ?ien if this bit is cleared, when the buffer transfer is completed, t he btc[x] flag is set in the ebcisr status register. this bit i s active low. ?auto automatic multiple buffer transfer is enabled. when set, this bit enables replay mode or contiguous mode when several buf- fers are transferred. fc type of transfer flow controller 000 memory-to-memory dma controller 001 memory-to-peripheral dma controller 010 peripheral-to-memory dma controller 011 peripheral-to-peripheral dma controller 100 peripheral-to-memory peripheral 101 memory-to-peripheral peripheral 110 peripheral-to-peripheral source peripheral 111 peripheral-to-peripheral destination peripheral src_incr type of addressing mode 00 incrementing 01 decrementing 10 fixed dst_incr type of addressing scheme 00 incrementing 01 decrementing 10 fixed
1023 6438fCatarmC21-jun-10 at91sam9g45 41.6.18 dmac channel x [x = 0..7] configuration register name: dmac_cfgx [x = 0..7] addresses: 0xffffec50 [0], 0xffffec78 [1], 0xffffeca0 [2], 0xffffecc8 [3], 0xffffecf0 [4], 0xffffed18 [5], 0xffffed40 [6], 0xffffed68 [7] access: read-write reset: 0x0100000000 ? src_per channel x source request is associated with peripher al identifier coded src_per handshaking interface. ? dst_per channel x destination request is associated with peripheral identifier coded dst_per handshaking interface. ?src_rep 0: when automatic mode is activated, source address is contiguous between two buffers. 1: when automatic mode is activated, the source address and the control register are reloaded from previous transfer. ? src_h2sel 0: software handshaking interface is used to trigger a transfer request. 1: hardware handshaking interface is used to trigger a transfer request. ? dst_rep 0: when automatic mode is activated, destination address is contiguous between two buffers. 1: when automatic mode is activated, the destination and the control register are reloaded from the previous transfer. ? dst_h2sel 0: software handshaking interface is used to trigger a transfer request. 1: hardware handshaking interface is used to trigger a transfer request. ?sod 0: stop on done disabled, the descriptor fetch operation ignores done field of ctrla register. 1: stop on done activated, the dmac module is automatically disabled if done field is set to 1. 31 30 29 28 27 26 25 24 C C fifocfg C ahb_prot 23 22 21 20 19 18 17 16 C lock_if_l lock_b lock_if C C C sod 15 14 13 12 11 10 9 8 C C dst_h2sel dst_rep C C src_h2sel src_rep 76543210 dst_per src_per
1024 6438fCatarmC21-jun-10 at91sam9g45 ?lock_if 0: interface lock capability is disabled 1: interface lock capability is enabled ?lock_b 0: ahb bus locking capability is disabled. 1: ahb bus locking capability is enabled. ?lock_if_l 0: the master interface arbiter is locked by the channel x for a chunk transfer. 1: the master interface arbiter is locked by the channel x for a buffer transfer. ? ahb_prot ahb_prot field provides additional information about a bus access and is primarily used to implement some level of protection. ? fifocfg hprot[3] hprot[2] hprot[1] hprot[0] description 1 data access ahb_prot[0] 0: user access 1: privileged access ahb_prot[1] 0: not bufferable 1: bufferable ahb_prot[2] 0: not cacheable 1: cacheable fifocfg fifo request 00 the largest defined length ahb burst is per formed on the destination ahb interface. 01 when half fifo size is available/filled, a source/destination request is serviced. 10 when there is enough space/data available to perform a single ahb access, then the request is serviced.
1025 6438fCatarmC21-jun-10 at91sam9g45 41.6.19 dmac channel x [x = 0..7] source picture in picture configuration register name: dmac_spipx [x = 0..7] addresses: 0xffffec54 [0], 0xffffec7c [1], 0xfff feca4 [2], 0xffffeccc [3], 0xffffecf4 [4], 0xffffed1c [5], 0xffffed44 [6], 0xffffed6c [7] access: read-write reset: 0x00000000 ? spip_hole this field indicates the value to add to the address when the programmable boundary has been reached. ? spip_boundary this field indicates the number of source transfers to perform before the automatic address increment operation. 31 30 29 28 27 26 25 24 CCCCCCspip_boundary 23 22 21 20 19 18 17 16 spip_boundary 15 14 13 12 11 10 9 8 spip_hole 76543210 spip_hole
1026 6438fCatarmC21-jun-10 at91sam9g45 41.6.20 dmac channel x [x = 0..7] destination picture in picture configuration register name: dmac_dpipx [x = 0..7] addresses: 0xffffec58 [0], 0xffffec80 [1], 0xffffeca8 [2], 0xffffecd0 [3], 0xffffecf8 [4], 0xffffed20 [5], 0xffffed48 [6], 0xffffed70 [7] access: read-write reset: 0x00000000 ? dpip_hole this field indicates the value to add to the address when the programmable boundary has been reached. ? dpip_boundary this field indicates the number of source transfers to perform before the automatic address increment operation. 31 30 29 28 27 26 25 24 CCCCCCdpip_boundary 23 22 21 20 19 18 17 16 dpip_boundary 15 14 13 12 11 10 9 8 dpip_hole 76543210 dpip_hole
1027 6438fCatarmC21-jun-10 at91sam9g45 42. pulse width modulation controller (pwm) 42.1 description the pwm macrocell controls several cha nnels independently. each channel controls one square output waveform. characteristics of the output waveform such as period, duty-cycle and polarity are configurable through the user interface. each channel selects and uses one of the clocks provided by the clock generator. the cloc k generator provides several clocks resulting from the division of the pwm macrocell master clock. all pwm macrocell accesses are made through apb mapped registers. channels can be synchronized, to generate non overlapped waveforms. all channels integrate a double buffering system in order to prevent an unexpected output waveform while modifying the period or the duty-cycle. 42.2 embedded characteristics ? four channels, one 16-bit counter per channel ? common clock generator, providing thirteen different clocks C a modulo n counter providing eleven clocks C two independent linear dividers working on modulo n counter outputs ? independent channel programming C independent enable disable commands C independent clock selection C independent period and duty cycle, with double buffering C programmable selection of the output waveform polarity C programmable center or left aligned output waveform
1028 6438fCatarmC21-jun-10 at91sam9g45 42.3 block diagram figure 42-1. pulse width modulation controller block diagram 42.4 i/o lines description each channel outputs one waveform on one external i/o line. 42.5 product dependencies 42.5.1 i/o lines the pins used for interfacing the pwm may be multiplexed with pio lines. the programmer must first program the pio controller to assign the desire d pwm pins to their peripheral function. if i/o lines of the pwm are not used by the applicati on, they can be used for other purposes by the pio controller. pwm controller apb pwmx pwmx pwmx channel update duty cycle counter pwm0 channel pio aic pmc mck clock generator apb interface interrupt generator clock selector period comparator update duty cycle counter clock selector period comparator pwm0 pwm0 table 42-1. i/o line description name description type pwmx pwm waveform output for channel x output
1029 6438fCatarmC21-jun-10 at91sam9g45 all of the pwm outputs may or may not be enabled. if an application requires only four channels, then only four pio lines will be assigned to pwm outputs. 42.5.2 power management the pwm is not continuously clocked. the programmer must first enable the pwm clock in the power management controller (pmc) before using the pwm. however, if the application does not require pwm operations, the pwm clock can be stopped when not needed and be restarted later. in this case, th e pwm will resume its operat ions where it left off. configuring the pwm does not require the pwm clock to be enabled. 42.5.3 interrupt sources the pwm interrupt line is connected on one of the internal sources of the advanced interrupt controller. using the pwm interrupt requires the ai c to be programmed first. note that it is not recommended to use the pwm interrupt line in edge sensitive mode. 42.6 functional description the pwm macrocell is primarily composed of a clock generator module and 4 channels. C clocked by the system clock, mck, the clock generator module provides 13 clocks. C each channel can independently choose one of the clock generator outputs. C each channel generates an output waveform with attributes that can be defined independently for each channel through the user interface registers. table 42-2. i/o lines instance signal i/o line peripheral pwm pwm0 pd24 b pwm pwm1 pd25 b pwm pwm1 pd31 b pwm pwm2 pd26 b pwm pwm2 pe31 a pwm pwm3 pa25 b pwm pwm3 pd0 b table 42-3. peripheral ids instance id pwm 19
1030 6438fCatarmC21-jun-10 at91sam9g45 42.6.1 pwm clock generator figure 42-2. functional view of the clock generator block diagram caution: before using the pwm macrocell, the pr ogrammer must first enable the pwm clock in the power management controller (pmc). the pwm macrocell master clock, mck, is divide d in the clock generator module to provide dif- ferent clocks available for all channels. each channel can independently select one of the divided clocks. the clock generator is divided in three blocks: C a modulo n counter which provides 11 clocks: f mck , f mck /2, f mck /4, f mck /8, f mck /16, f mck /32, f mck /64, f mck /128, f mck /256, f mck /512, f mck /1024 C two linear dividers (1, 1/2, 1/3, ... 1/255) that provide two separate clocks: clka and clkb each linear divider can independently divide one of the clocks of the modulo n counter. the selection of the clock to be divided is made ac cording to the prea (preb) field of the pwm mode register (pwm_mr). the resulting clock clka (clkb) is the clock selected divided by diva (divb) field value in the pwm mode register (pwm_mr). modulo n counter mck mck/2 mck/4 mck/16 mck/32 mck/64 mck/8 divider a clka diva pwm_mr mck mck/128 mck/256 mck/512 mck/1024 prea divider b clkb divb pwm_mr preb
1031 6438fCatarmC21-jun-10 at91sam9g45 after a reset of the pwm controller, diva (divb) and prea (preb) in the pwm mode register are set to 0. this implies that after reset clka (clkb) are turned off. at reset, all clocks provided by the modulo n counter are turned off except clock clk. this situa- tion is also true when the pwm master cl ock is turned off through the power management controller. 42.6.2 pwm channel 42.6.2.1 block diagram figure 42-3. functional view of the channel block diagram each of the 4 channels is composed of three blocks: ? a clock selector which selects one of the clocks provided by the clock generator described in section 42.6.1 pwm clock generator on page 1030 . ? an internal counter clocked by the output of the clock selector. this internal counter is incremented or decremented according to the channel configuration and comparators events. the size of the internal counter is 16 bits. ? a comparator used to generate events according to the internal counter value. it also computes the pwmx output waveform according to the configuration. 42.6.2.2 waveform properties the different properties of output waveforms are: ? the internal clock selection . the internal channel counter is clocked by one of the clocks provided by the clock generator described in the previous section. this channel parameter is defined in the cpre field of the pwm_cmrx register. this field is reset at 0. ? the waveform period . this channel parameter is defined in the cprd field of the pwm_cprdx register. - if the waveform is left aligned, then the output waveform period depends on the counter source clock and can be calculated: by using the master clock (mck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024), the resulting period formula will be: by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: comp a r a tor pwmx o u tp u t w a veform intern a l co u nter clock s elector inp u t s from clock gener a tor inp u t s from apb bus ch a nnel x cprd () mck -------------------------------
1032 6438fCatarmC21-jun-10 at91sam9g45 or if the waveform is center aligned then the output waveform period depends on the counter source clock and can be calculated: by using the master clock (mck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024 ). the resulting period formula will be: by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or ? the waveform duty cycle . this channel parameter is defined in the cdty field of the pwm_cdtyx register. if the waveform is left aligned then: if the waveform is center aligned, then: ? the waveform polarity. at the beginning of the period, the signal can be at high or low level. this property is defined in the cpol field of the pwm_cmrx register. by default the signal starts by a low level. ? the waveform alignment . the output waveform can be left or center aligned. center aligned waveforms can be used to generate non overlapped waveforms. this property is defined in the calg field of the pwm_cmrx register. the default mode is left aligned. figure 42-4. non overlapped center aligned waveforms note: 1. see figure 42-5 on page 1034 for a detailed description of center aligned waveforms. x * cprd * diva () mck --------------------------------------------- - x * cprd * divb () mck --------------------------------------------- - 2 xcprd () mck ---------------------------------------- - 2* x * cprd * diva () mck --------------------------------------------------- - 2* x * cprd * divb () mck --------------------------------------------------- - duty cycle period 1 fchannel_x_clock cdty ? ? () period ------------------------------------------------------------------------------------------------------- - = duty cycle period 2 ? () 1 fchannel_x_clock cdty ? ? ()) period 2 ? () ---------------------------------------------------------------------------------------------------------------------- - = pwm0 pwm1 period no overlap
1033 6438fCatarmC21-jun-10 at91sam9g45 when center aligned, the internal channel count er increases up to cprd and.decreases down to 0. this ends the period. when left aligned, the internal channel counter increases up to cprd and is reset. this ends the period. thus, for the same cprd value, the period for a ce nter aligned channel is twice the period for a left aligned channel. waveforms are fixed at 0 when: ? cdty = cprd and cpol = 0 ? cdty = 0 and cpol = 1 waveforms are fixed at 1 (once the channel is enabled) when: ? cdty = 0 and cpol = 0 ? cdty = cprd and cpol = 1 the waveform polarity must be set before enabling the channel. this immediately affects the channel output level. changes on channel polari ty are not taken into account while the channel is enabled.
1034 6438fCatarmC21-jun-10 at91sam9g45 figure 42-5. waveform properties pwm_mckx chidx(pwm_sr) center aligned cprd(pwm_cprdx) cdty(pwm_cdtyx) pwm_ccntx output waveform pwmx cpol(pwm_cmrx) = 0 output waveform pwmx cpol(pwm_cmrx) = 1 chidx(pwm_isr) left aligned cprd(pwm_cprdx) cdty(pwm_cdtyx) pwm_ccntx output waveform pwmx cpol(pwm_cmrx) = 0 output waveform pwmx cpol(pwm_cmrx) = 1 chidx(pwm_isr) calg(pwm_cmrx) = 0 calg(pwm_cmrx) = 1 period period chidx(pwm_ena) chidx(pwm_dis)
1035 6438fCatarmC21-jun-10 at91sam9g45 42.6.3 pwm controller operations 42.6.3.1 initialization before enabling the output channel, this chann el must have been configured by the software application: ? configuration of the clock generator if diva and divb are required ? selection of the clock for each channel (cpre field in the pwm_cmrx register) ? configuration of the waveform alignment for each channel (calg field in the pwm_cmrx register) ? configuration of the period for each channel (cprd in the pwm_cprdx register). writing in pwm_cprdx register is possible while the channel is disabled. after validation of the channel, the user must use pwm_cupdx register to update pwm_cprdx as explained below. ? configuration of the duty cycl e for each channel (cdty in the pwm_cdtyx register). writing in pwm_cdtyx register is possible while the channel is disabled. after validation of the channel, the user must use pwm_cupdx register to update pwm_cdtyx as explained below. ? configuration of the output waveform polarity for each channel (cpol in the pwm_cmrx register) ? enable interrupts (writing chidx in the pwm_ier register) ? enable the pwm channel (writing chidx in the pwm_ena register) it is possible to synchronize different channels by enabling them at the same time by means of writing simultaneously several chidx bits in the pwm_ena register. ? in such a situation, all channels may have the same clock selector configuration and the same period specified. 42.6.3.2 source clock selection criteria the large number of source clocks can make selection difficult. the relationship between the value in the period register (pwm_cprdx) an d the duty cycle regi ster (pwm_cdtyx) can help the user in choosing. the event number written in the period register gives the pwm accu- racy. the duty cycle quantum cannot be lower than 1/pwm_cprdx value. the higher the value of pwm_cprdx, the greater the pwm accuracy. for example, if the user sets 15 (in decimal) in pwm_cprdx, the user is able to set a value between 1 up to 14 in pwm_cdtyx register. the resulting duty cycle quantum cannot be lower than 1/15 of the pwm period. 42.6.3.3 changing the duty cycle or the period it is possible to modulate the output waveform duty cycle or period. to prevent unexpected output waveform, the user must use the update register (pwm_cupdx) to change waveform parameters while the channel is still enabled. the user can write a new period value or duty cycle value in the update re gister (pwm_cupdx). this register holds the new value until the end of the current cycle and updates the value for the next cycle. depending on the cpd field in the pwm_cmrx regist er, pwm_cupdx either updates pwm_cprdx or pwm_cdtyx. note that even if the update register is used, the period must not be smaller than the duty cycle.
1036 6438fCatarmC21-jun-10 at91sam9g45 figure 42-6. synchronized period or duty cycle update to prevent overwriting the pwm_cupdx by software , the user can use status events in order to synchronize his software. two methods are possibl e. in both, the user must enable the dedi- cated interrupt in pwm_ier at pwm controller level. the first method ( polling method) consists of reading the relevant status bit in pwm_isr regis- ter according to the enabled channel(s). see figure 42-7 . the second method uses an interrupt service routine associated with the pwm channel. note: reading the pwm_isr register automatically clears chidx flags. figure 42-7. polling method note: polarity and alignment can be modified only when the channel is disabled. pwm_cupdx value pwm_cprdx pwm_cdtyx end of cycle pwm_cmrx. cpd user's writing 1 0 writing in pwm_cupdx the last write has been taken into account chidx = 1 writing in cpd field update of the period or duty cycle pwm_isr read acknowledgement and clear previous register state yes
1037 6438fCatarmC21-jun-10 at91sam9g45 42.6.3.4 interrupts depending on the interrupt mask in the pwm_imr register, an interrupt is generated at the end of the corresponding channel period. the interrupt remains active until a read operation in the pwm_isr register occurs. a channel interrupt is enabled by setting the corresponding bit in the pwm_ier register. a chan- nel interrupt is disabled by setting the corresponding bit in the pwm_idr register.
1038 6438fCatarmC21-jun-10 at91sam9g45 42.7 pulse width modulation cont roller (pwm) user interface 2. some registers are indexed with ch_num index ranging from 0 to 3. table 42-4. register mapping () offset register name access reset 0x00 pwm mode register pwm_mr read-write 0 0x04 pwm enable register pwm_ena write-only - 0x08 pwm disable register pwm_dis write-only - 0x0c pwm status register pwm_sr read-only 0 0x10 pwm interrupt enable register pwm_ier write-only - 0x14 pwm interrupt disable register pwm_idr write-only - 0x18 pwm interrupt mask register pwm_imr read-only 0 0x1c pwm interrupt status register pwm_isr read-only 0 0x20 - 0xfc reserved C C C 0x100 - 0x1fc reserved 0x200 + ch_num * 0x20 + 0x00 pwm channel mode register pwm_cmr read-write 0x0 0x200 + ch_num * 0x20 + 0x04 pwm channel duty cycle register pwm_cdty read-write 0x0 0x200 + ch_num * 0x20 + 0x08 pwm channel period register pwm_cprd read-write 0x0 0x200 + ch_num * 0x20 + 0x0c pwm channel counter register pwm_ccnt read-only 0x0 0x200 + ch_num * 0x20 + 0x10 pwm channel update register pwm_cupd write-only -
1039 6438fCatarmC21-jun-10 at91sam9g45 42.7.1 pwm mode register register name: pwm_mr address: 0xfffb8000 access type: read/write ? diva, divb: clka, clkb divide factor ? prea, preb 31 30 29 28 27 26 25 24 CCCC preb 23 22 21 20 19 18 17 16 divb 15 14 13 12 11 10 9 8 CCCC prea 76543210 diva diva, divb clka, clkb 0 clka, clkb clock is turned off 1 clka, clkb clock is clock selected by prea, preb 2-255 clka, clkb clock is clock selected by prea, preb divided by diva, divb factor. prea, preb divider input clock 0000mck. 0001mck/2 0010mck/4 0011mck/8 0100mck/16 0101mck/32 0110mck/64 0111mck/128 1000mck/256 1001mck/512 1010mck/1024 other reserved
1040 6438fCatarmC21-jun-10 at91sam9g45 42.7.2 pwm enable register register name: pwm_ena address: 0xfffb8004 access type: write-only ? chidx: channel id 0 = no effect. 1 = enable pwm output for channel x. 42.7.3 pwm disable register register name: pwm_dis address: 0xfffb8008 access type: write-only ? chidx: channel id 0 = no effect. 1 = disable pwm output for channel x. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCchid3chid2chid1chid0 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCchid3chid2chid1chid0
1041 6438fCatarmC21-jun-10 at91sam9g45 42.7.4 pwm status register register name: pwm_sr address: 0xfffb800c access type: read-only ? chidx: channel id 0 = pwm output for channel x is disabled. 1 = pwm output for channel x is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCchid3chid2chid1chid0
1042 6438fCatarmC21-jun-10 at91sam9g45 42.7.5 pwm interrupt enable register register name: pwm_ier address: 0xfffb8010 access type: write-only ? chidx: channel id. 0 = no effect. 1 = enable interrupt for pwm channel x. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCchid3chid2chid1chid0
1043 6438fCatarmC21-jun-10 at91sam9g45 42.7.6 pwm interrupt disable register register name: pwm_idr address: 0xfffb8014 access type: write-only ? chidx: channel id. 0 = no effect. 1 = disable interrupt for pwm channel x. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCchid3chid2chid1chid0
1044 6438fCatarmC21-jun-10 at91sam9g45 42.7.7 pwm interrupt mask register register name: pwm_imr address: 0xfffb8018 access type: read-only ? chidx: channel id. 0 = interrupt for pwm channel x is disabled. 1 = interrupt for pwm channel x is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCchid3chid2chid1chid0
1045 6438fCatarmC21-jun-10 at91sam9g45 42.7.8 pwm interrupt status register register name: pwm_isr address: 0xfffb801c access type: read-only ? chidx: channel id 0 = no new channel period has been achieved si nce the last read of the pwm_isr register. 1 = at least one new channel period has been achiev ed since the last read of the pwm_isr register. note: reading pwm_isr automa tically clears chidx flags. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCchid3chid2chid1chid0
1046 6438fCatarmC21-jun-10 at91sam9g45 42.7.9 pwm channel mode register register name: pwm_cmr[0..3] addresses: 0xfffb8200 [0], 0xfffb8220 [1], 0xfffb8240 [2], 0xfffb8260 [3] access type: read/write ? cpre: channel pre-scaler ? calg: channel alignment 0 = the period is left aligned. 1 = the period is center aligned. ? cpol: channel polarity 0 = the output waveform starts at a low level. 1 = the output waveform starts at a high level. ? cpd: channel update period 0 = writing to the pwm_cupdx will modify the duty cycle at the next period start event. 1 = writing to the pwm_cupdx will modify th e period at the next period start event. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCcpdcpolcalg 76543210 CCCC cpre cpre channel pre-scaler 0000mck 0001mck/2 0010mck/4 0011mck/8 0100mck/16 0101mck/32 0110mck/64 0111mck/128 1000mck/256 1001mck/512 1010mck/1024 1011clka 1100clkb other reserved
1047 6438fCatarmC21-jun-10 at91sam9g45 42.7.10 pwm channel duty cycle register register name: pwm_cdty[0..3] addresses: 0xfffb8204 [0], 0xfffb8224 [1], 0xfffb8244 [2], 0xfffb8264 [3] access type: read/write only the first 16 bits (internal ch annel counter size) are significant. ? cdty: channel duty cycle defines the waveform duty cycle. this value must be defined between 0 and cprd (pwm_cprx). 31 30 29 28 27 26 25 24 cdty 23 22 21 20 19 18 17 16 cdty 15 14 13 12 11 10 9 8 cdty 76543210 cdty
1048 6438fCatarmC21-jun-10 at91sam9g45 42.7.11 pwm channel period register register name: pwm_cprd[0..3] addresses: 0xfffb8208 [0], 0xfffb8228 [1], 0xfffb8248 [2], 0xfffb8268 [3] access type: read/write only the first 16 bits (internal ch annel counter size) are significant. ? cprd: channel period if the waveform is left-aligned, then the output waveform period depends on the counter source clock and can be calculated: C by using the master clock (mck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). the resu lting period formula will be: C by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or if the waveform is center-aligned, then the output waveform period depends on the counter source clock and can be calculated: C by using the master clock (mck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024) . the resulting pe riod formula will be: C by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or 31 30 29 28 27 26 25 24 cprd 23 22 21 20 19 18 17 16 cprd 15 14 13 12 11 10 9 8 cprd 76543210 cprd xcprd () mck ------------------------------- crpd diva () mck ------------------------------------------ crpd divab () mck ---------------------------------------------- 2 xcprd () mck ---------------------------------------- - 2 cprd diva () mck --------------------------------------------------- - 2 cprd divb () mck --------------------------------------------------- -
1049 6438fCatarmC21-jun-10 at91sam9g45 42.7.12 pwm channel counter register register name: pwm_ccnt[0..3] addresses: 0xfffb820c [0], 0xfffb822c [1], 0xfffb824c [2], 0xfffb826c [3] access type: read-only ? cnt: channel counter register internal counter value. this register is reset when: ? the channel is enabled (writing chidx in the pwm_ena register). ? the counter reaches cprd value defined in the pwm_ cprdx register if the waveform is left aligned. 31 30 29 28 27 26 25 24 cnt 23 22 21 20 19 18 17 16 cnt 15 14 13 12 11 10 9 8 cnt 76543210 cnt
1050 6438fCatarmC21-jun-10 at91sam9g45 42.7.13 pwm channel update register register name: pwm_cupd[0..3] addresses: 0xfffb8210 [0], 0xfffb8230 [1], 0xfffb8250 [2], 0xfffb8270 [3] access type: write-only this register acts as a double buffer for the period or the duty cycle. this prevents an unexpected waveform when modify- ing the waveform period or duty-cycle. only the first 16 bits (internal ch annel counter size) are significant. 31 30 29 28 27 26 25 24 cupd 23 22 21 20 19 18 17 16 cupd 15 14 13 12 11 10 9 8 cupd 76543210 cupd cpd (pwm_cmrx register) 0 the duty-cycle (cdty in the pwm_cdtyx regist er) is updated with the cupd value at the beginning of the next period. 1 the period (cprd in the pwm_cprdx register) is updated with the cupd value at the beginning of the next period.
1051 6438fCatarmC21-jun-10 at91sam9g45 43. ac97 controller (ac97c) 43.1 description the ac97 controller is the hardware implementation of the ac97 digital controller (dc97) com- pliant with ac97 component specification 2.2. the ac97 controller communicates with an audio codec (ac97) or a modem codec (mc97) via the ac-link digital serial interface. all digital audio, modem and handset data streams, as well as control (command/status) informations are transferred in accordance to the ac-link protocol. the ac97 controller features a peripheral dma controller (pdc) for audio streaming transfers. it also supports variable sampling rate and four pulse code modulation (pcm) sample resolu- tions of 10, 16, 18 and 20 bits. 43.2 embedded characteristics ? compatible with ac97 component specification v2.2 ? capable to interface with a single analog front end ? three independent rx channels and three independent tx channels C one rx and one tx channel dedicated to the ac97 analog front end control C one rx and one tx channel for data transfers, associated with a pdc C one rx and one tx channel for data transfers with no pdc ? time slot assigner allowing to assign up to 12 time slots to a channel ? channels support mono or stereo up to 20 bit sample length C variable sampling rate ac97 codec interface (48khz and below)
1052 6438fCatarmC21-jun-10 at91sam9g45 43.3 block diagram figure 43-1. functional block diagram ac97 channel a ac97c_cathr ac97c_carhr slot #3...12 ac97 codec channel ac97c_cothr ac97c_corhr slot #2 slot #1,2 ac97 channel b ac97c_cbthr ac97c_cbrhr slot #3...12 ac97 tag controller transmit shift register receive shift register receive shift register receive shift register receive shift register transmit shift register transmit shift register transmit shift register slot #0 slot #0,1 ac97 slot controller slot number 16/20 bits slot number sdata_in bitclk sdata_out sync user interface mck clock domain bit clock domain ac97c interrupt mck apb interface m u x d e m u x
1053 6438fCatarmC21-jun-10 at91sam9g45 43.4 pin name list the ac97 reset signal provided to the primary codec can be generated by a pio. 43.5 application block diagram figure 43-2. application block diagram table 43-1. i/o lines description pin name pin description type ac97ck 12.288-mhz bit-rate clock input ac97rx receiver data (referred as sdata_in in ac-link spec) input ac97fs 48-khz frame indicator and synchronizer output ac97tx transmitter data (referred as sdata_out in ac-link spec) output ac 97 controller ac97tx ac97rx piox ac'97 primary codec ac97fs ac97ck ac97_reset ac97_sync ac97_sdata_out ac97_bitclk ac-link ac97_sdata_in
1054 6438fCatarmC21-jun-10 at91sam9g45 43.6 product dependencies 43.6.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with pio lines. before using the ac97 controller receiver, the pio controller must be configured in order for the ac97c receiver i/o lines to be in ac97 controller peripheral mode. before using the ac97 controller transmitter, the pio controller must be configured in order for the ac97c transmitter i/o lines to be in ac97 controlle r peripheral mode. 43.6.2 power management the ac97 controller is not continuously clocked. its interface may be clocked through the power management controller (pmc), therefore the programmer must first configure the pmc to enable the ac97 controller clock. the ac97 controller has two clock domains. t he first one is supplied by pmc and is equal to mck. the second one is ac97ck which is sent by the ac97 codec (bit clock). signals that cross the two clock domains are re-synchronized. mck clock frequency must be higher than the ac97ck (bit clock) clock frequency. 43.6.3 interrupt the ac97 controller interface has an interrupt line connected to the advanced interrupt control- ler (aic). handling interrupts requires programming the aic before configuring the ac97c. all ac97 controller interrupts can be enabled/dis abled by writing to the ac97 controller inter- rupt enable/disable registers. each pending and unmasked ac97 controller interrupt will assert the interrupt line. the ac97 controller interrupt service routine can get the interrupt source in two steps: ? reading and anding ac97 controller interrupt mask register (ac97c_imr) and ac97 controller status register (ac97c_sr). ? reading ac97 controller channel x status register (ac97c_cxsr). table 43-2. i/o lines instance signal i/o line peripheral ac97c ac97ck pd9 a ac97c ac97fs pd8 a ac97c ac97rx pd6 a ac97c ac97tx pd7 a table 43-3. peripheral ids instance id ac97c 24
1055 6438fCatarmC21-jun-10 at91sam9g45 43.7 functional description 43.7.1 protocol overview ac-link protocol is a bidirectional, fixed clock rate, serial digital stream. ac-link handles multiple input and output pulse code modulation pcm audio streams, as well as control register accesses employing a time division multiplexed (tdm) scheme that divides each audio frame in 12 outgoing and 12 incoming 20-bit wide data slots. figure 43-3. bidirectional ac-link fr ame with slot assignment slot # ac97fs tag cmd addr cmd data 0 ac97tx (controller output) ac97rx (codec output) pcm l front pcm r front line 1 dac pcm center pcm r surr pcm lfe line 2 dac hset dac io ctrl tag status addr status data pcm left line 1 dac pcm mic rsved rsved rsved line 2 adc hset adc io status 12 3 4 56 7 8 9 1011 12 pcm l surr pcm right table 43-4. ac-link output slots transmitted from the ac97c controller slot # pin description 0tag 1 command address port 2 command data port 3,4 pcm playback left/right channel 5 modem line 1 output channel 6, 7, 8 pcm center/le ft surround/right surround 9pcm lfe dac 10 modem line 2 output channel 11 modem handset output channel 12 modem gpio control channel table 43-5. ac-link input slots transmitte d from the ac97c controller slot # pin description 0tag 1 status address port 2 status data port 3,4 pcm playback left/right channel 5 modem line 1 adc 6 dedicated microphone adc 7, 8, 9 vendor reserved 10 modem line 2 adc 11 modem handset input adc 12 modem io status
1056 6438fCatarmC21-jun-10 at91sam9g45 43.7.2 slot description 43.7.2.1 tag slot the tag slot, or slot 0, is a 16-bit wide slot that always goes at the beginning of an outgoing or incoming frame. within tag slot, the first bit is a global bit that flags the entire frame validity. the next 12 bit positions sampled by the ac97 cont roller indicate which of the corresponding 12 time slots contain valid data. the slots last two bits (combined) called codec id, are used to dis- tinguish primary and secondary codec. the 16-bit wide tag slot of the output frame is automatically generated by the ac97 controller according to the transmit request of each channel and to the slotreq from the previous input frame, sent by the ac97 codec, in variable sample rate mode. 43.7.2.2 codec slot 1 the command/status slot is a 20-bit wide slot used to control features, and monitors status for ac97 codec functions. the control interface architecture supports up to sixty-four 16-bit wide read-write registers. only the even registers are currently defined and addressed. slot 1s bitmap is the following: ? bit 19 is for read-write command, 1= read, 0 = write. ? bits [18:12] are for control register index. ? bits [11:0] are reserved. 43.7.2.3 codec slot 2 slot 2 is a 20-bit wide slot used to carry 16-bit wide ac97 codec control register data. if the cur- rent command port operation is a read, the entire slot time is stuffed with zeros. its bitmap is the following: ? bits [19:4] are the control register data ? bits [3:0] are reserved and stuffed with zeros. 43.7.2.4 data slots [3:12] slots [3:12] are 20-bit wide data slots, they usually carry audio pcm and/or modem i/o data.
1057 6438fCatarmC21-jun-10 at91sam9g45 43.7.3 ac97 controller channel organization the ac97 controller features a codec channel and 2 logical channels: channel a, channel b. the codec channel controls ac 97 codec registers, it enables write and read configuration val- ues in order to bring the ac97 codec to an operating state. the codec channel always runs slot 1 and slot 2 exclusively, in both input and output directions. channel a, channel b transfer data to/from ac97 codec. all audio samples and modem data must transit by these 2 channels. however, channels a and b are connected to pdc channels thus making it suitable for audio streaming applications. each slot of the input or the output frame that belongs to this range [3 to 12] can be operated by channel a or channel b . the slot to channel assignment is configured by two registers: ? ac97 controller input channel assignment register (ac97c_ica) ? ac97 controller output channel assignment register (ac97c_oca) the ac97 controller input channel assignment register (ac97c_ica) configures the input slot to channel assignment. the ac97 controlle r output channel assignment register (ac97c_oca) configures the output slot to channel assignment. a slot can be left unassigned to a channel by the ac97 controller. slots 0, 1,and 2 cannot be assigned to channel a or to channel bthr ough the ac97c_oca and ac97c_ica registers. the width of sample data, that transit via the ch annel varies and can take one of these values; 10, 16, 18 or 20 bits. figure 43-4. logical channel assignment slot # ac97fs tag cmd data 0 ac97tx (controller output) ac97rx (codec output) pcm l front pcm r front line 1 dac pcm center pcm l surr pcm r surr pcm lfe line 2 dac hset dac io ctrl tag status addr status data pcm left pcm right line 1 dac pcm mic rsved rsved rsved line 2 adc hset adc io status 12 3 4 56 7 8 91011 12 codec channel channel a codec channel channel a ac97c_oca = 0x0000_0209 ac97c_ica = 0x0000_0009 cmd addr
1058 6438fCatarmC21-jun-10 at91sam9g45 43.7.3.1 ac97 controller setup the following operations must be performed in order to bring the ac97 controller into an operat- ing state: 1. enable the ac97 controller clock in the pmc controller. 2. turn on ac97 function by enabling the ena bit in ac97 controller mode register (ac97c_mr). 3. configure the input channe l assignment by controlling the ac97 controller input assignment register (ac97c_ica). 4. configure the output channel assignment by controlling the ac97 controller input assignment register (ac97c_oca). 5. configure sample width for channel a, chan nel bby writing the size bit field in ac97c channel x mode register (ac97c_camr), (ac97c_cbmr). the application can write 10, 16, 18,or 20-bit wide pcm samples thro ugh the ac97 interface and they will be transferred into 20-bit wide slots. 6. configure data endianness for channel a, channel b by writing cem bit field in (ac97c_camr), (ac97c_cbmr) register. data on the ac-link are shifted msb first. the application can write little- or big-endian data to the ac97 controller interface. 7. configure the pio controller to drive the reset signal of the external codec. the reset signal must fulfill external ac97 codec timing requirements. 8. enable channel a and/or channel b by writing cen bit field in ac97c_cxmr register. 43.7.3.2 transmit operation the application must perform the following steps in order to send data via a channel to the ac97 codec: ? check if previous data has been sent by polling txrdy flag in the ac97c channel x status register (ac97_cxsr). x being one of the 2 channels. ? write data to the ac97 controller channel x transmit holding regi ster (ac97c_cxthr). once data has been transferred to the channel x shift register, the txrdy flag is automatically set by the ac97 controller which allows the application to start a new write action. the applica- tion can also wait for an interrupt notice associated with txrdy in order to send data. the interrupt remains active until txrdy flag is cleared.
1059 6438fCatarmC21-jun-10 at91sam9g45 figure 43-5. audio transfer (pcm l front, pcm r front) on channel x the txempty flag in the ac97 controller channel x status register (ac97c_cxsr) is set when all requested transmissions for a channel have been shifted on the ac-link. the applica- tion can either poll txempty flag in ac97c_cxs r or wait for an interrupt notice associated with the same flag. in most cases, the ac97 controller is embedded in chips that target audio player devices. in such cases, the ac97 controller is exposed to heavy audio transfers. using the polling tech- nique increases processor overhead and may fail to keep the required pace under an operating system. in order to avoid thes e polling drawbacks, the applicati on can perform audio streams by using pdc connected to channel a, which r educes processor overhead and increases perfor- mance especially under an operating system. the pdc transmit counter values must be equal to the number of pcm samples to be transmit- ted, each sample goes in one slot. 43.7.3.3 ac97 output frame the ac97 controller outputs a thirteen-slot frame on the ac-link. the first slot (tag slot or slot 0) flags the validity of the entire frame and the validity of each slot; whether a slot carries valid data or not. slots 1 and 2 are used if the application performs control and status monitoring actions on ac97 codec control/status registers. slots [3:12] are used according to the content of the ac97 controller output channel assignment register (ac97c_oca). if the application per- forms many transmit requests on a channel, some of the slots associated to this channel or all of them will carry valid data. 43.7.3.4 receive operation the ac97 controller can also receive data from ac97 codec. data is received in the channels shift register and then transferred to the ac97 controller channel x read holding register. to read the newly received data, the application must perform the following steps: ? poll rxrdy flag in ac97 controller channel x status register (ac97c_cxsr). x being one of the 2 channels. ? read data from ac97 controller channel x read holding register. slot # ac97fs tag cmd addr cmd data 0 ac97tx (controller output) pcm l front pcm r front line 1 dac pcm center pcm l surr pcm r surr pcm lfe line 2 dac hset dac io ctrl 12 3 4 56 7 8 9 1011 12 txrdycx (ac97c_sr) write access to ac97c_thrx pcm l front transfered to the shift register pcm r front transfered to the shift register txempty (ac97c_sr)
1060 6438fCatarmC21-jun-10 at91sam9g45 the application can also wait for an interrupt notice in order to read data from ac97c_cxrhr. the interrupt remains active until rx rdy is cleared by reading ac97c_cxsr. the rxrdy flag in ac97c_cxsr is set automatic ally when data is received in the channel x shift register. data is th en shifted to ac97c_cxrhr. figure 43-6. audio transfer (pcm l front, pcm r front) on channel x if the previously received data has not been read by the application, the new data overwrites the data already waiting in ac97c _cxrhr, therefore the ovrun flag in ac97c_cxsr is raised. the application can either poll the ovrun flag in ac97c_cxsr or wait for an interrupt notice. the interrupt remains acti ve until the ovrun flag in ac97c_cxsr is set. the ac97 controller can also be used in sound re cording devices in association with an ac97 codec. the ac97 controller may also be exposed to heavy pcm transfers. the application can use the pdc connected to channel a in order to reduce processor overhead and increase per- formance especially under an operating system. the pdc receive counter values must be equal to the number of pcm samples to be received, each sample goes in one slot. 43.7.3.5 ac97 input frame the ac97 controller receives a thirteen slot frame on the ac-link sent by the ac97 codec. the first slot (tag slot or slot 0) fl ags the validity of the entire frame and the validity of each slot; whether a slot carries valid data or not. slots 1 and 2 are used if the application requires status informations from ac97 codec. slots [3:12] are used according to ac97 controller output channel assignment register (ac97c_ica) co ntent. the ac97 contro ller will not receive any data from any slot if ac97c_ica is not assigned to a channel in input. 43.7.3.6 configuring and using interrupts instead of polling flags in ac97 controller global status register (ac97c_sr) and in ac97 controller channel x status register (ac97c_c xsr), the application can wait for an interrupt notice. the following steps show how to configure and use interrupts correctly: ? set the interruptible flag in ac97 controller channel x mode register (ac97c_cxmr). ? set the interruptible event and channel event in ac97 controller interrupt enable register (ac97c_ier). the interrupt handler must read both ac97 controller global status register (ac97c_sr) and ac97 controller interrupt mask register (ac97c_imr) and and them to get the real interrupt source. furthermore, to get which event was activated, the interrupt handler has to read ac97 controller channel x status register (ac97c_cxsr), x being the channel whose event triggers the interrupt. slot # ac97fs 0123 4 56 7 8 9 1011 12 rxrdycx (ac97c_sr) read access to ac97c_rhrx ac97rx (codec output) tag status addr status data pcm left pcm right line 1 dac pcm mic rsved rsved rsved line 2 adc hset adc io status
1061 6438fCatarmC21-jun-10 at91sam9g45 the application can disable event interrupts by writing in ac97 controlle r interrupt disable reg- ister (ac97c_idr). the ac97 controller interrupt mask register (ac97c_imr) shows which event can trigger an interrupt and which one cannot. 43.7.3.7 endianness endianness can be managed automatically for each channel, except for the codec channel, by writing to channel endianness mode (cem) in ac97c_cxmr. this enables transferring data on ac-link in big endian format without any additional operation. 43.7.3.8 to transmit a word stored in big endian format on ac-link word to be written in ac97 controller channel x transmit holding register (ac97c_cxthr) (as it is stored in memory or microprocessor register). word stored in channel x transmit holding register (ac97c_cxthr) (data to transmit) . data transmitted on appropriate slot: data[19:0] = {byte2[3:0], byte1[7:0], byte0[7:0]}. 43.7.3.9 to transmit a halfword stored in big indian format on ac-link halfword to be written in ac97 controlle r channel x transmit holding register (ac97c_cxthr). halfword stored in ac97 cont roller channel x transmit holdin g register (ac97c_cxthr) (data to transmit). data emitted on related slot: data[19:0] = {0x0, byte1[7:0], byte0[7:0]}. 43.7.3.10 to transmit a10-bit sample stored in big endian format on ac-link halfword to be written in ac97 controlle r channel x transmit holding register (ac97c_cxthr). halfword stored in ac97 cont roller channel x transmit holdin g register (ac97c_cxthr) (data to transmit). data emitted on related slot: data[19:0] = {0x000, byte1[1:0], byte0[7:0]}. 31 24 23 16 15 8 7 0 byte0[7:0] byte1[7:0] byte2[7:0] byte3[7:0] 31 24 23 20 19 16 15 8 7 0 C C byte2[3:0] byt e1[7:0] byte0[7:0] 31 24 23 16 15 8 7 0 C C byte0[7:0] byte1[7:0] 31 24 23 16 15 8 7 0 C C byte1[7:0] byte0[7:0] 31 24 23 16 15 8 7 0 C C byte0[7:0] {0x00, byte1[1:0]} 31 24 23 16 15 10 9 8 7 0 CCC byte1 [1:0] byte0[7:0]
1062 6438fCatarmC21-jun-10 at91sam9g45 43.7.3.11 to receive word transfers data received on appropriate slot: data[19:0] = {byte2[3:0], byte1[7:0], byte0[7:0]}. word stored in ac97 cont roller channel x receive hold ing register (ac97c_cxrhr) (received data) . data is read from ac97 cont roller channel x rece ive holding register (ac97c_cxrhr) when channel x data size is greater than 16 bits and when big-endian mode is enabled (data written to memory). 43.7.3.12 to receive halfword transfers data received on appropriate slot: data[19:0] = {0x0, byte1[7:0], byte0[7:0]}. halfword stored in ac97 controller channel x receive holding register (ac97c_cxrhr) (received data). data is read from ac97 cont roller channel x rece ive holding register (ac97c_cxrhr) when data size is equal to 16 bits and when big-endian mode is enabled. 43.7.3.13 to receiv e 10-bit samples data received on appropriate slot: data[19:0] = {0x000, byte1[1:0], byte0[7:0]}.halfword stored in ac97 controller channel x receive holding register (ac97c_cxrhr) (received data) data read from ac97 contro ller channel x receive holdin g register (ac97c_cxrhr) when data size is equal to 10 bits and when big-endian mode is enabled. 31 24 23 20 19 16 15 8 7 0 C C byte2[3:0] byt e1[7:0] byte0[7:0] 31 24 23 16 15 8 7 0 byte0[7:0] byte1[7:0] {0x0, byte2[3:0]} 0x00 31 24 23 16 15 8 7 0 C C byte1[7:0] byte0[7:0] 31 24 23 16 15 8 7 0 C C byte0[7:0] byte1[7:0] 31 24 23 16 15 10 9 8 7 0 CCC byte1 [1:0] byte0[7:0] 31 24 23 16 15 8 7 3 1 0 C C byte0[7:0] 0x00 byte1 [1:0]
1063 6438fCatarmC21-jun-10 at91sam9g45 43.7.4 variable sample rate the problem of variable sample rate can be summarized by a simple example. when passing a 44.1 khz stream across the ac-link, for every 480 audio output frames that are sent across, 441 of them must contain valid sample data. the new ac97 standard approach calls for the addition of on-demand slot request flags. the ac97 co dec examines its sample rate control register, the state of its fifos, and the incoming sdata_out tag bits (slot 0) of each output frame and then determines which slotreq bits to set acti ve (low). these bits are passed from the ac97 codec to the ac97 controller in slot 1/slotreq in every audio input frame. each time the ac97 controller sees one or more of the newly defined slot request flags set active (low) in a given audio input frame, it must pass along the next pcm sample for the corresponding slot(s) in the ac-link output frame that immediately follows. the variable sample rate mode is enabled by performing the following steps: ? setting the vra bit in the ac97 controller mode register (ac97c_mr). ? enable variable rate mode in the ac97 codec by performing a transfer on the codec channel. slot 1 of the input frame is automatically interpreted as slotreq signaling bits. the ac97 con- troller will automatically fill the active sl ots according to both slotreq and ac97c_oca register in the next transmitted frame. 43.7.5 power management 43.7.5.1 powering down the ac-link the ac97 codecs can be placed in low power mo de. the application can bring ac97 codec to a power down state by performing sequential writes to ac97 codec powerdown register. both the bit clock (clock delivered by ac97 codec, ac97ck) and the input line (ac97rx) are held at a logic low voltage level. this puts ac97 codec in power down state while all its registers are still holding current values. without the bit cloc k, the ac-link is completely in a power down state. the ac97 controller should not attempt to pl ay or capture audio data until it has awakened ac97 codec. to set the ac97 codec in low power mode, t he pr4 bit in the ac97 codec powerdown register (codec address 0x26) must be set to 1. t hen the primary codec drives both ac97ck and ac97rx to a low logic voltage level. the following operations must be done to put ac97 codec in low power mode: ? disable channel a clearing cen field in the ac97c_camr register. ? disable channel b clearing cen field in the ac97c_cbmr register. ? write 0x2680 value in the ac97c_cothr register. ? poll the txempty flag in ac97c_cxsr registers for the 2 channels. at this point ac97 code c is in low power mode. 43.7.5.2 waking up the ac-link there are two methods to bring the ac-link out of low power mode. regardless of the method, it is always the ac97 controller that performs the wake-up. 43.7.5.3 wake-up triggered by the ac97 controller the ac97 controller can wake up the ac97 codec by issuing either a cold or a warm reset.
1064 6438fCatarmC21-jun-10 at91sam9g45 the ac97 controller can also wake up the ac97 codec by asserti ng ac97fs signal, however this action should not be performed for a minimum period of four audio frames following the frame in which the powerdown was issued. 43.7.5.4 wake-up triggered by the ac97 codec this feature is implemented in ac97 modem codec s that need to report events such as caller- id and wake-up on ring. the ac97 codec can drive ac97rx signal from low to high level and holding it high until the controller issues either a cold or a worm reset. the ac97rx rising edge is asynchronously (regarding ac97fs) detected by the ac97 controller. if wkup bit is enabled in ac97c_imr register, an interrupt is triggered that wakes up the ac97 controller which should then immedi- ately issue a cold or a warm reset. if the processor needs to be awakened by an external event, the ac97rx signal must be exter- nally connected to the wakeup entry of the sys tem controller. figure 43-7. ac97 power-down/up sequence 43.7.5.5 ac97 codec reset there are three ways to reset an ac97 codec. 43.7.5.6 cold ac97 reset a cold reset is generated by asserting the reset signal low for the minimum specified time (depending on the ac97 codec) and then by de-asserting reset high. ac97ck and ac97fs is reactivated and all ac97 codec registers are set to their default power-on values. transfers on ac-link can resume. the reset signal will be controlled via a pio line. th is is how an applicat ion should perform a cold reset: ? clear and set ena flag in the ac97c_mr register to reset the ac97 controller ? clear pio line output cont rolling the ac97 reset signal ? wait for the minimum specified time ? set pio line output contro lling the ac97 reset signal ac97ck, the clock provided by ac97 co dec, is detected by the controller. 43.7.5.7 warm ac97 reset a warm reset reactivates the ac-link without alteri ng ac97 codec registers. a warm reset is sig- naled by driving ac97fx signal high for a minimum of 1us in the absence of ac97ck. in the ac97ck ac97fs tag write to 0x26 data pr4 power down frame sleep state tag write to 0x26 data pr4 wake event warm reset new audio frame tag slot1 slot2 ac97tx ac97rx tag slot1 slot2
1065 6438fCatarmC21-jun-10 at91sam9g45 absence of ac97ck, ac97fx is treated as an asynchronous (regarding ac97fx) input used to signal a warm reset to ac97 codec. this is the right way to perform a warm reset: ? set wrst in the ac97c_mr register. ? wait for at least 1us ? clear wrst in the ac97c_mr register. the application can check that operations have resumed by checking sof flag in the ac97c_sr register or wait for an interrupt notice if sof is enabled in ac97c_imr.
1066 6438fCatarmC21-jun-10 at91sam9g45 43.8 ac97 controller (a c97c) user interface table 43-6. register mapping offset register name access reset 0x0-0x4 reserved C C C 0x8 mode register ac97c_mr read-write 0x0 0xc reserved C C C 0x10 input channel assignment register ac97c_ica read-write 0x0 0x14 output channel assignment register ac97c_oca read-write 0x0 0x18-0x1c reserved C C C 0x20 channel a receive holding register ac97c_carhr read 0x0 0x24 channel a transmit holding register ac97c_cathr write C 0x28 channel a status register ac97c_casr read 0x0 0x2c channel a mode register ac97c_camr read-write 0x0 0x30 channel b receive holding register ac97c_cbrhr read 0x0 0x34 channel b transmit holding register ac97c_cbthr write C 0x38 channel b status register ac97c_cbsr read 0x0 0x3c channel b mode register ac97c_cbmr read-write 0x0 0x40 codec channel receive holding register ac97c_corhr read 0x0 0x44 codec channel transmit holding register ac97c_cothr write C 0x48 codec status register ac97c_cosr read 0x0 0x4c codec mode register ac97c_comr read-write 0x0 0x50 status register ac97c_sr read 0x0 0x54 interrupt enable register ac97c_ier write C 0x58 interrupt disable register ac97c_idr write C 0x5c interrupt mask register ac97c_imr read 0x0 0x60-0xfb reserved C C C 0x100-0x124 reserved for peripheral dma controller (pdc) registers related to channel transfers C C C
1067 6438fCatarmC21-jun-10 at91sam9g45 43.8.1 ac97 controller mode register register name: ac97c_mr address: 0xfffac008 access type: read-write ? vra: variable rate (for data slots 3-12) 0: variable rate is inactive. (48 khz only) 1: variable rate is active. ? wrst: warm reset 0: warm reset is inactive. 1: warm reset is active. ? ena: ac97 controller global enable 0: no effect. ac97 function as well as access to other ac97 controller registers are disabled. 1: activates the ac97 function. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCvrawrstena
1068 6438fCatarmC21-jun-10 at91sam9g45 43.8.2 ac97 controller input channel assignment register register name :ac97c_ica address: 0xfffac010 access type : read-write ? chidx: channel id for the input slot x 31 30 29 28 27 26 25 24 C C chid12 chid11 23 22 21 20 19 18 17 16 chid10 chid9 chid8 15 14 13 12 11 10 9 8 chid8 chid7 chid6 chid5 76543210 chid5 chid4 chid3 chidx selected receive channel 0x0 none. no data will be received during this slot time 0x1 channel a data will be received during this slot time. 0x2 channel b data will be received during this slot time
1069 6438fCatarmC21-jun-10 at91sam9g45 43.8.3 ac97 controller output channel assignment register register name :ac97c_oca address: 0xfffac014 access type : read-write ? chidx: channel id for the output slot x 31 30 29 28 27 26 25 24 C C chid12 chid11 23 22 21 20 19 18 17 16 chid10 chid9 chid8 15 14 13 12 11 10 9 8 chid8 chid7 chid6 chid5 76543210 chid5 chid4 chid3 chidx selected transmit channel 0x0 none. no data will be transmitted during this slot time 0x1 channel a data will be transferred during this slot time. 0x2 channel b data will be transferred during this slot time
1070 6438fCatarmC21-jun-10 at91sam9g45 43.8.4 ac97 controller codec channel receive holding register register name :ac97c_corhr address: 0xfffac040 access type : read-only ?sdata: status data data sent by the codec in the third ac97 input frame slot (slot 2). 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 sdata 76543210 sdata
1071 6438fCatarmC21-jun-10 at91sam9g45 43.8.5 ac97 controller codec channel transmit holding register register name :ac97c_cothr address: 0xfffac044 access type : write-only ? read: read-write command 0: write operation to the codec r egister indexed by the caddr address. 1: read operation to the codec register indexed by the caddr address. this flag is sent during the second ac97 frame slot ? caddr: codec control register index data sent to the codec in the second ac97 frame slot. ? cdata: command data data sent to the codec in the third ac97 frame slot (slot 2). 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 read caddr 15 14 13 12 11 10 9 8 cdata 76543210 cdata
1072 6438fCatarmC21-jun-10 at91sam9g45 43.8.6 ac97 controller channel a, channel b, receive holding register register name :ac97c_carhr, ac97c_cbrhr address: 0xfffac020 address: 0xfffac030 access type : read-only ? rdata: receive data received data on channel x. 43.8.7 ac97 controller channel a, channel b, transmit holding register register name :ac97c_cathr, ac97c_cbthr address: 0xfffac024 address: 0xfffac034 access type : write-only ? tdata: transmit data data to be sent on channel x. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCC rdata 15 14 13 12 11 10 9 8 rdata 76543210 rdata 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCC tdata 15 14 13 12 11 10 9 8 tdata 76543210 tdata
1073 6438fCatarmC21-jun-10 at91sam9g45 43.8.8 ac97 controller channel a status register register name :ac97c_casr address: 0xfffac028 access type : read-only ? txrdy: channel transmit ready 0: data has been loaded in channel transmit register and is waiting to be loaded in the channel transmit shift register. 1: channel transmit register is empty. ? txempty: channel transmit empty 0: data remains in the channel transmit register or is currently transmitted from the channel transmit shift register. 1: data in the channel transmit register have been loaded in the channel transmit shift register and sent to the codec. ? unrun: transmit underrun active only when variable rate mode is enabled (vra bit set in the ac97c_mr register). automatically cleared by a pro- cessor read operation. 0: no data has been requested from the channel since the last read of the status register, or data has been available each time the codec requested new data from the channel since the last read of the status register. 1: data has been emitted while no valid data to send has been previously loaded into the channel transmit shift register since the last read of the status register. ? rxrdy: channel receive ready 0: channel receive holding register is empty. 1: data has been received and loaded in channel receive holding register. ? ovrun: receive overrun automatically cleared by a processor read operation. 0: no data has been loaded in the channel receive holding register while previous data has not been read since the last read of the status register. 1: data has been loaded in the channel receive holding regi ster while previous data has not yet been read since the last read of the status register. ? endtx: end of transmission for channel a 0: the register ac97c_ca tcr has not reached 0 sinc e the last write in ac97c_catcr or ac97c_cancr. 1: the register ac97c_ catcr has reached 0 sinc e the last write in ac97c_catcr or ac97c_catncr. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 rxbuff endrx C C txbufe endtx C C 76543210 C C ovrun rxrdy C unrun txempty txrdy
1074 6438fCatarmC21-jun-10 at91sam9g45 ? txbufe: transmit buffer empty for channel a 0: ac97c_catcr or ac97c_catncr have a value other than 0. 1: both ac97c_catcr and ac97c_catncr have a value of 0. ? endrx: end of reception for channel a 0: the register ac97c_carcr has not reached 0 sinc e the last write in ac97c_carcr or ac97c_carncr. 1: the register ac97c_carcr has reached 0 since the last write in ac97c_carcr or ac97c_carncr. ? rxbuff: receive buffer full for channel a 0: ac97c_carcr or ac97c_carncr have a value other than 0. 1: both ac97c_carcr and ac97c_carncr have a value of 0.
1075 6438fCatarmC21-jun-10 at91sam9g45 43.8.9 ac97 controller channel b status register register name :ac97c_cbsr address: 0xfffac038 access type : read-only ? txrdy: channel transmit ready 0: data has been loaded in channel transmit register and is waiting to be loaded in the channel transmit shift register. 1: channel transmit register is empty. ? txempty: channel transmit empty 0: data remains in the channel transmit register or is currently transmitted from the channel transmit shift register. 1: data in the channel transmit register have been loaded in the channel transmit shift register and sent to the codec. ? unrun: transmit underrun active only when variable rate mode is enabled (vra bit set in the ac97c_mr register). automatically cleared by a pro- cessor read operation. 0: no data has been requested from the channel since the last read of the status register, or data has been available each time the codec requested new data from the channel since the last read of the status register. 1: data has been emitted while no valid data to send has been previously loaded into the channel transmit shift register since the last read of the status register. ? rxrdy: channel receive ready 0: channel receive holding register is empty. 1: data has been received and loaded in channel receive holding register. ? ovrun: receive overrun automatically cleared by a processor read operation. 0: no data has been loaded in the channel receive holding register while previous data has not been read since the last read of the status register. 1: data has been loaded in the channel receive holding regi ster while previous data has not yet been read since the last read of the status register. ? endtx: end of transmission for channel b 0: the register ac97c_cb tcr has not reached 0 sinc e the last write in ac97c_cbtcr or ac97c_cbncr. 1: the register ac97c_ cbtcr has reached 0 sinc e the last write in ac97c_cbtcr or ac97c_cbtncr. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 rxbuff endrx C C C txbufe endtx C 76543210 C C ovrun rxrdy C unrun txempty txrdy
1076 6438fCatarmC21-jun-10 at91sam9g45 ? txbufe: transmit buffer empty for channel b 0: ac97c_cbtcr or ac97c_cbtncr have a value other than 0. 1: both ac97c_cbtcr and ac97c_cbtncr have a value of 0. ? endrx: end of reception for channel b 0: the register ac97c_cbrcr has not reached 0 sinc e the last write in ac97c_cbrcr or ac97c_cbrncr. 1: the register ac97c_cbrcr has reached 0 since the last write in ac97c_cbrcr or ac97c_cbrncr. ? rxbuff: receive buffer full for channel b 0: ac97c_cbrcr or ac97c_cbrncr have a value other than 0. 1: both ac97c_cbrcr and ac97c_cbrncr have a value of 0.
1077 6438fCatarmC21-jun-10 at91sam9g45 43.8.10 ac97 controller codec status register register name : ac97c_cosr address: 0xfffac048 access type : read-only ? txrdy: channel transmit ready 0: data has been loaded in channel transmit register and is waiting to be loaded in the channel transmit shift register. 1: channel transmit register is empty. ? txempty: channel transmit empty 0: data remains in the channel transmit register or is currently transmitted from the channel transmit shift register. 1: data in the channel transmit register have been loaded in the channel transmit shift register and sent to the codec. ? unrun: transmit underrun active only when variable rate mode is enabled (vra bit set in the ac97c_mr register). automatically cleared by a pro- cessor read operation. 0: no data has been requested from the channel since the last read of the status register, or data has been available each time the codec requested new data from the channel since the last read of the status register. 1: data has been emitted while no valid data to send has been previously loaded into the channel transmit shift register since the last read of the status register. ? rxrdy: channel receive ready 0: channel receive holding register is empty. 1: data has been received and loaded in channel receive holding register. ? ovrun: receive overrun automatically cleared by a processor read operation. 0: no data has been loaded in the channel receive holding register while previous data has not been read since the last read of the status register. 1: data has been loaded in the channel receive holding regi ster while previous data has not yet been read since the last read of the status register. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C ovrun rxrdy C unrun txempty txrdy
1078 6438fCatarmC21-jun-10 at91sam9g45 43.8.11 ac97 controller channel a mode register register name :ac97c_camr address: 0xfffac02c access type : read-write ? txrdy: channel transmit ready interrupt enable ? txempty: channel transmit empty interrupt enable ? unrun: transmit underrun interrupt enable ? rxrdy: channel receive ready interrupt enable ? ovrun: receive overrun interrupt enable ? endtx: end of transmission for channel a interrupt enable ? txbufe: transmit buffer empty for channel a interrupt enable 0: read: the corresponding interrupt is disabled. write: disables the corresponding interrupt. 1: read: the corresponding interrupt is enabled. write: enables the corresponding interrupt. ? endrx: end of reception for channel a interrupt enable 0: read: the corresponding interrupt is disabled. write: disables the corresponding interrupt. 1: read: the corresponding interrupt is enabled. write: enables the corresponding interrupt. ? rxbuff: receive buffer full for channel a interrupt enable 0: read: the corresponding interrupt is disabled. write: disables the corresponding interrupt. 1: read: the corresponding interrupt is enabled. write: enables the corresponding interrupt. ? size: channel a data size size encoding note: each time slot in the data phase is 20 bit long. for example, if a 16-bit sample stream is being played to an ac 97 dac, t he first 16 bit positions are presented to the dac msb-justified. they ar e followed by the next four bit positions that the ac97 control ler 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 C pdcen cen C C cem size 15 14 13 12 11 10 9 8 rxbuff endrx C C txbufe endtx C C 76543210 C C ovrun rxrdy C unrun txempty txrdy size selected data size 0x0 20 bits 0x1 18 bits 0x2 16 bits 0x3 10 bits
1079 6438fCatarmC21-jun-10 at91sam9g45 fills with zeroes. this process ensures that the least significant bits do not introduce any dc biasing, regardless of the impl e- mented dacs resolution (16-, 18-, or 20-bit) ? cem: channel a endian mode 0: transferring data through channel a is straight forward (little-endian). 1: transferring data through channel a from/to a memory is performed with from/to big-endian format translation. ? cen: channel a enable 0: data transfer is disabled on channel a. 1: data transfer is enabled on channel a. ? pdcen: peripheral data controller channel enable 0: channel a is not transferred through a peripheral data controller channel. related pdc flags are ignored or not generated. 1: channel a is transferred through a peripheral data controller channel. related pdc flags are taken into account or generated.
1080 6438fCatarmC21-jun-10 at91sam9g45 43.8.12 ac97 controller channel b mode register register name :ac97c_cbmr address: 0xfffac03c access type : read-write ? txrdy: channel transmit ready interrupt enable ? txempty: channel transmit empty interrupt enable ? unrun: transmit underrun interrupt enable ? rxrdy: channel receive ready interrupt enable ? ovrun: receive overrun interrupt enable ? endtx: end of transmission for channel b interrupt enable ? txbufe: transmit buffer empty for channel b interrupt enable 0: read: the corresponding interrupt is disabled. write: disables the corresponding interrupt. 1: read: the corresponding interrupt is enabled. write: enables the corresponding interrupt. ? endrx: end of reception for channel b interrupt enable 0: read: the corresponding interrupt is disabled. write: disables the corresponding interrupt. 1: read: the corresponding interrupt is enabled. write: enables the corresponding interrupt. ? rxbuff: receive buffer full for channel b interrupt enable 0: read: the corresponding interrupt is disabled. write: disables the corresponding interrupt. 1: read: the corresponding interrupt is enabled. write: enables the corresponding interrupt. ? size: channel b data size size encoding note: each time slot in the data phase is 20 bit long. for example, if a 16-bit sample stream is being played to an ac 97 dac, t he first 16 bit positions are presented to the dac msb-justified. they ar e followed by the next four bit positions that the ac97 control ler 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 C pdcen cen C C cem size 15 14 13 12 11 10 9 8 rxbuff endrx C C txbufe endtx C C 76543210 C C ovrun rxrdy C unrun txempty txrdy size selected data size 0x0 20 bits 0x1 18 bits 0x2 16 bits 0x3 10 bits
1081 6438fCatarmC21-jun-10 at91sam9g45 fills with zeroes. this process ensures that the least significant bits do not introduce any dc biasing, regardless of the impl e- mented dacs resolution (16-, 18-, or 20-bit) ? cem: channel b endian mode 0: transferring data through channel b is straight forward (little-endian). 1: transferring data through channel b from/to a memory is performed with from/to big-endian format translation. ? cen: channel b enable 0: data transfer is disabled on channel b. 1: data transfer is enabled on channel b. ? pdcen: peripheral data controller channel enable 0: channel b is not transferred through a peripheral data controller channel. related pdc flags are ignored or not generated. 1: channel b is transferred through a peripheral data controller channel. related pdc flags are taken into account or generated.
1082 6438fCatarmC21-jun-10 at91sam9g45 43.8.13 ac97 controller codec mode register register name : ac97c_comr address: 0xfffac04c access type : read-write ? txrdy: channel transmit ready interrupt enable ? txempty: channel transmit empty interrupt enable ? unrun: transmit underrun interrupt enable ? rxrdy: channel receive ready interrupt enable ? ovrun: receive overrun interrupt enable 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C ovrun rxrdy C unrun txempty txrdy
1083 6438fCatarmC21-jun-10 at91sam9g45 43.8.14 ac97 controller status register register name :ac97c_sr address: 0xfffac050 access type : read-only wkup and sof flags in ac97c_sr register are auto matically cleared by a processor read operation. ? sof: start of frame 0: no start of frame has been detected since the last read of the status register. 1: at least one start of frame has been detected since the last read of the status register. ? wkup: wake up detection 0: no wake-up has been detected. 1: at least one rising edge on sdata_in has been asynch ronously detected. that means ac97 codec has notified a wake-up. ? coevt: codec channel event a codec channel event occurs when ac97c _cosr and ac97c_comr is not 0. co evt flag is automatically cleared when the channel event condition is cleared. 0: no event on the codec channel has been detected since the last read of the status register. 1: at least one event on th e codec channel is active. ? caevt: channel a event a channel a event occurs when ac97c_casr and ac97c_camr is not 0. caevt flag is automatica lly cleared when the channel event condition is cleared. 0: no event on the channel a has been detected since the last read of the status register. 1: at least one event on the channel a is active. ? cbevt: channel b event a channel b event occurs when ac97c_cbsr and ac97c_cbmr is not 0. cbevt flag is automatica lly cleared when the channel event condition is cleared. 0: no event on the channel b has been detected since the last read of the status register. 1: at least one event on the channel b is active. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C cbevt caevt coevt wkup sof
1084 6438fCatarmC21-jun-10 at91sam9g45 43.8.15 ac97 codec controller interrupt enable register register name :ac97c_ier address: 0xfffac054 access type : write-only ? sof: start of frame ?wkup: wake up ? coevt: codec event ? caevt: channel a event ? cbevt: channel b event 0: no effect. 1: enables the corresponding interrupt. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C cbevt caevt coevt wkup sof
1085 6438fCatarmC21-jun-10 at91sam9g45 43.8.16 ac97 controller interrupt disable register register name :ac97c_idr address: 0xfffac058 access type : write-only ? sof: start of frame ?wkup: wake up ? coevt: codec event ? caevt: channel a event ? cbevt: channel b event 0: no effect. 1: disables the corresponding interrupt. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C cbevt caevt coevt wkup sof
1086 6438fCatarmC21-jun-10 at91sam9g45 43.8.17 ac97 controller interrupt mask register register name :ac97c_imr address: 0xfffac05c access type : read-only ? sof: start of frame ?wkup: wake up ? coevt: codec event ? caevt: channel a event ? cbevt: channel b event 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C cbevt caevt coevt wkup sof
1087 6438fCatarmC21-jun-10 at91sam9g45 44. true random numb er generator (trng) 44.1 description the true random number generator (trng) passes the american nist special publication 800-22 and diehard random tests suites. as soon as the trng is enabled (trng_ctrl register), the generator provides one 32-bit value every 84 clock cycles. interrupt trng_int can be enabled through the trng_ier register (respectively disabled in trng_idr). this interrupt is set when a new random value is available and is cleared when the status register is read (trng_sr register). the flag datrdy of the status register (trng_isr) is set when the random data is ready to be read out on the 32-bit output data register (trng_odata). the normal mode of operation checks that the status register flag equals 1 before reading the output data register when a 32-bit random value is required by the software application. figure 44-1. trng data generation sequence 84 clock cycles 84 clock cycles 84 clock cycles read trng_isr read trng_odata read trng_isr read trng_odata clock trng_int trng_cr enable
1088 6438fCatarmC21-jun-10 at91sam9g45 44.2 true random number genera tor (trng) user interface table 44-1. register mapping offset register name access reset 0x00 control register trng_cr write-only C 0x10 interrupt enable register trng_ier write-only C 0x14 interrupt disable register trng_idr write-only C 0x18 interrupt mask register trng_imr read-only 0x0000 0x1c interrupt status r egister trng_isr read-only 0x0000 0x50 output data register trng_odata read-only 0x0000
1089 6438fCatarmC21-jun-10 at91sam9g45 44.2.1 trng control register name: trng_cr address: 0xfffcc000 access type: write-only ? enable: enables the trng to provide random values 0 = disables the trng. 1 = enables the trng. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCenable
1090 6438fCatarmC21-jun-10 at91sam9g45 44.2.2 trng interrupt enable register name: trng_ier address: 0xfffcc010 access type: write-only ? datrdy: data ready interrupt enable 0 = no effect. 1 = enables the corresponding interrupt. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCdatrdy
1091 6438fCatarmC21-jun-10 at91sam9g45 44.2.3 trng interrupt disable register name: trng_idr address: 0xfffcc014 access type: write-only ? datrdy: data ready interrupt disable 0 = no effect. 1 = disables the corresponding interrupt. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCdatrdy
1092 6438fCatarmC21-jun-10 at91sam9g45 44.2.4 trng interrupt mask register name: trng_imr address: 0xfffcc018 reset: 0x0000 access type: read-only ? datrdy: data ready interrupt mask 0 = the corresponding interrupt is not enabled. 1 = the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCCCCdatrdy
1093 6438fCatarmC21-jun-10 at91sam9g45 44.2.5 trng interrupt status register name: trng_isr address: 0xfffcc01c reset: 0x0000 access type: read-only ? datrdy: data ready 0 = output data is not valid or trng is disabled. 1 = new random value is completed. datrdy is cleared when this register is read. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCC 76543210 CCCCCCCdatrdy
1094 6438fCatarmC21-jun-10 at91sam9g45 44.2.6 trng output data register name: trng_odata address: 0xfffcc050 reset: 0x0000 access type: read-only ? odata: output data the 32-bit output data register contains the 32-bit random data. 31 30 29 28 27 26 25 24 odata 23 22 21 20 19 18 17 16 odata 15 14 13 12 11 10 9 8 odata 76543210 odata
1095 6438fCatarmC21-jun-10 at91sam9g45 45. lcd controller (lcdc) 45.1 description the lcd controller (lcdc) consists of logic for transferring lcd image data from an external display buffer to an lcd module with integrated common and segment drivers. the lcd controller supports single and double scan monochrome and color passive stn lcd modules and single scan active tft lcd modules. on monochrome stn displays, up to 16 gray shades are supported using a time-based dithering algorithm and frame rate control (frc) method. this method is also used in colo r stn displays to generate up to 4096 colors. the lcd controller has a display input buffer (fifo) to allow a flexible connection of the exter- nal ahb master interface, and a lookup table to allow palletized display configurations. the lcd controller is programmable in order to support many different requirements such as resolutions up to 2048 x 2048; pixel depth (1, 2, 4, 8, 16, 24 bits per pixel); data line width (4, 8, 16 or 24 bits) and interface timing. the lcd controller is connected to the arm advanced high performance bus (ahb) as a mas- ter for reading pixel data. however, the lcd cont roller interfaces with the ahb as a slave in order to configure its registers. 45.2 embedded characteristics ? single and dual scan color and monochrome passive stn lcd panels supported ? single scan active tft lcd panels supported. ? 4-bit single scan, 8-bit single or dual scan , 16-bit dual scan stn interfaces supported ? up to 24-bit single scan tft interfaces supported ? up to 16 gray levels for mono stn and up to 4096 colors for color stn displays ? 1, 2 bits per pixel (palletized), 4 bits per pixel (non-palletized) for mono stn ? 1, 2, 4, 8 bits per pixel (palletized), 16 bits per pixel (non-palletized) for color stn ? 1, 2, 4, 8 bits per pixel (palletized), 16, 24 bits per pixel (non-palletized) for tft ? single clock domain architecture ? resolution supported up to 2048 x 2048
1096 6438fCatarmC21-jun-10 at91sam9g45 45.3 block diagram figure 45-1. lcd macrocell block diagram timegen pwm display cfg ch-l ahb if ch-u ctrl cfg ahb slave display if ahb master split lut mem fifo mem dma controller lcd controller core configuration if control interface lower push fifo serializer palette dithering output shifter ahb slave ahb slave input interface upper push dma data lcdd display if control signals dvalid dvalid lut mem interface fifo mem interface lut mem interface data pat h
1097 6438fCatarmC21-jun-10 at91sam9g45 45.4 i/o lines description 45.5 product dependencies 45.5.1 i/o lines the pins used for interfacing the lcd controller may be multiplexed with pio lines. the pro- grammer must first program the pio controller to assign the pins to their peripheral function. if i/o lines of the lcd controller are not used by the application, they can be used for other pur- poses by the pio controller. table 45-1. i/o lines description name description type lcdcc contrast control signal output lcdhsync line synchronous signal (stn) or horizontal synchronous signal (tft) output lcddotck lcd clock signal (stn/tft) output lcdvsync frame synchronous signal (stn) or ve rtical synchronization signal (tft) output lcdden data enable signal output lcdmod lcd modulation signal output lcdpwr lcd panel power enable control signal output lcdd[23:0] lcd data bus output output table 45-2. i/o lines instance signal i/o line peripheral lcdc lcdcc pe2 a lcdc lcdden pe6 a lcdc lcddotck pe5 a lcdc lcdd0 pe7 a lcdc lcdd1 pe8 a lcdc lcdd2 pe7 b lcdc lcdd2 pe9 a lcdc lcdd3 pe8 b lcdc lcdd3 pe10 a lcdc lcdd4 pe9 b lcdc lcdd4 pe11 a lcdc lcdd5 pe10 b lcdc lcdd5 pe12 a lcdc lcdd6 pe11 b lcdc lcdd6 pe13 a lcdc lcdd7 pe12 b lcdc lcdd7 pe14 a lcdc lcdd8 pe15 a
1098 6438fCatarmC21-jun-10 at91sam9g45 45.5.2 power management the lcd controller is not continuously clocked. the user must first enable the lcd controller clock in the power management contro ller before using it (pmc_pcer). lcdc lcdd9 pe16 a lcdc lcdd10 pe13 b lcdc lcdd10 pe17 a lcdc lcdd11 pe14 b lcdc lcdd11 pe18 a lcdc lcdd12 pe15 b lcdc lcdd12 pe19 a lcdc lcdd13 pe16 b lcdc lcdd13 pe20 a lcdc lcdd14 pe17 b lcdc lcdd14 pe21 a lcdc lcdd15 pe18 b lcdc lcdd15 pe22 a lcdc lcdd16 pe23 a lcdc lcdd17 pe24 a lcdc lcdd18 pe19 b lcdc lcdd18 pe25 a lcdc lcdd19 pe20 b lcdc lcdd19 pe26 a lcdc lcdd20 pe21 b lcdc lcdd20 pe27 a lcdc lcdd21 pe22 b lcdc lcdd21 pe28 a lcdc lcdd22 pe23 b lcdc lcdd22 pe29 a lcdc lcdd23 pe24 b lcdc lcdd23 pe30 a lcdc lcdhsync pe4 a lcdc lcdmod pe1 a lcdc lcdpwr pe0 a lcdc lcdvsync pe3 a table 45-2. i/o lines (continued)
1099 6438fCatarmC21-jun-10 at91sam9g45 45.5.3 interrupt sources the lcd controller interrupt line is connected to one of the internal sources of the advanced interrupt controller. using the lcd controller interrupt requires prior programming of the aic. 45.6 functional description the lcd controller consists of two main blocks ( figure 45-1 on page 1096 ), the dma controller and the lcd controller core (lcdc core). the dma controller reads the display data from an external memory through a ahb master interface. the lcd controller core formats the display data. the lcd controller core continuously pumps the pixel data into the lcd module via the lcd data bus (lcdd[23:0]); this bus is timed by the lcddotck, lcdden, lcdhsync, and lcdvsync signals. 45.6.1 dma controller 45.6.1.1 configuration block the configuration block is a set of programmable registers that are used to configure the dma controller operation. these registers are written vi a the ahb slave interface. only word access is allowed. for details on the configuration registers, see lcd controller (lcdc) user interface on page 1125 . 45.6.1.2 ahb interface this block generates the ahb transactions. it generates undefined-length incrementing bursts as well as 4-, 8- or 16-beat incrementing bursts. the size of the transfer can be configured in the brstln field of the dmafrmcfg register. for details on this register, see dma frame con- figuration register on page 1130 . 45.6.1.3 channel-u this block stores the base address and the number of words transferred for this channel (frame in single scan mode and upper panel in dual scan mode) since the beginning of the frame. it also generates the end of frame signal. it has two pointers, the base address and the number of words to transfer. when the module receives a new_frame signal, it reloads the number of words to transfer pointer with the size of the frame/panel. when the module receives the new_frame signal, it also reloads the base address with the base address programmed by the host. the size of the frame/panel can be programmed in the frmsize field of the dmafrmcfg register. this size is calculated as follows: where: x_size = ((linesize +1)*bpp+pixeloff)/32 y_size = (lineval+1) table 45-3. peripheral ids instance id lcdc 23 frame_size x_size*y_size 32 ------------------------------------- - =
1100 6438fCatarmC21-jun-10 at91sam9g45 ? linesize is the horizontal size of the display in pixels, minus 1, as programmed in the linesize field of the lcdfrmcfg register of the lcd controller. ?bpp is the number of bits per pixel configured. ?pixeloff is the pixel offset for 2d addressing, as programmed in the dma2dcfg register. applicable only if 2d addressing is being used. ? lineval is the vertical size of the display in pixels, minus 1, as programmed in the lineval field of the lcdfrmcfg register of the lcd controller. note: x_size is calculated as an up-rounding of a division by 32. (this can also be done adding 31 to the dividend before using an integer division by 32). when using the 2d-addressing mode (see 2d memory addressing on page 1122 ), it is important to note that the above calculation must be exe- cuted and the frmsize field programmed with ever y movement of the displaying window, since a change in the pixeloff field can change the resulting frmsize value. 45.6.1.4 channel-l this block has the same functionality as channel- u, but for the lower panel in dual scan mode only. 45.6.1.5 control this block receives the request signals from the lcdc core and generates the requests for the channels. 45.6.2 lcd controller core 45.6.2.1 configuration block the configuration block is a set of programmable registers that are used to configure the lcdc core operation. these registers are written via the ahb slave interface. only word access is allowed. the description of the configuration registers can be found in lcd controller (lcdc) user interface on page 1125 . 45.6.2.2 datapath the datapath block contains five submodules: fif o, serializer, palette, dithering and shifter. the structure of the datapath is shown in figure 45-2 .
1101 6438fCatarmC21-jun-10 at91sam9g45 figure 45-2. datapath structure this module transforms the data read from the memory into a format according to the lcd mod- ule used. it has four different interfaces: the input interface, the output interface, the configuration interface and the control interface. ? the input interface connects the datapath with the dma controller. it is a dual fifo interface with a data bus and two push lines that are used by the dma controller to fill the fifos. ? the output interface is a 24-bit data bus. the configuration of this interface depends on the type of lcd used (tft or stn, single or dual scan, 4-bit, 8-bit, 16-bit or 24-bit interface). ? the configuration interface connects the datapath with the configuration block. it is used to select between the different datapath configurations. ? the control interface connects the datapath with the timing generation block. the main control signal is the data-request signal, used by the timing generation module to request new data from the datapath. the datapath can be characterized by two parameters: initial_latency and cycles_per_data. the parameter initial_latency is defin ed as the number of lcdc core clock cycles until the first data is available at the output of the datapath. th e parameter cycles_per_data is the minimum num- ber of lcdc core clock cycles between two consecutive data at the output interface. fifo serializer palette dithering output shifter input interface output interface configuration if control interface
1102 6438fCatarmC21-jun-10 at91sam9g45 these parameters are different for the different configurations of the lcd controller and are shown in table 45-4 . 45.6.2.3 fifo the fifo block buffers the input data read by the dma module. it contains two input fifos to be used in dual scan configuration that are configured as a single fifo when used in single scan configuration. the size of the fifos allows a wide range of architectures to be supported. the upper threshold of the fifos can be configured in the fifoth field of the lcdfifo regis- ter. the lcdc core will request a dm a transfer when the number of words in each fifo is less than fifoth words. to avoid overwriting in the fifo and to maximize the fifo utilization, the fifoth should be programmed with: fifoth (in words) = 512 - (2 x dma_burst_length + 3) where: ? 512 is the effective size of the fifo in words. it is the total fifo memory size in single scan mode and half that size in dual scan mode. ? dma_burst_length is the burst length of the transfers made by the dma in words. 45.6.2.4 serializer this block serializes the data read from memory. it reads words from the fifo and outputs pix- els (1 bit, 2 bits, 4 bits, 8 bits, 16 bits or 24 bits wide) depending on the format specified in the pixelsize field of the lcdcon2 register. it also adapts the memory-ordering format. both big- endian and little-endian formats are supported. they are configured in the memor field of the lcdcon2 register. the organization of the pixel data in the memory depends on the configur ation and is shown in table 45-5 and table 45-7 . note: for a color depth of 24 bits per pixel ther e are two different formats supported: packed and unpacked. the packed format needs less memory but has some limitations when working in 2d addressing mode ( see 2d memory addressing on page 1122. ). table 45-4. datapath parameters configuration initial_latency cycles_per_data distype scan ifwidth tft 9 1 stn mono single 4 13 4 stn mono single 8 17 8 stn mono dual 8 17 8 stn mono dual 16 25 16 stn color single 4 11 2 stn color single 8 12 3 stn color dual 8 14 4 stn color dual 16 15 6
1103 6438fCatarmC21-jun-10 at91sam9g45 table 45-6. little endian memory organization mem addr 0x3 0x2 0x1 0x0 bit313029282726252423222120191817161514131211109876543210 pixel 1bpp 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9876543210 pixel 2bpp 15 14 13 12 11 10 9 876543210 pixel 4bpp 7 6 5 4 3 2 1 0 pixel 8bpp 3210 pixel 16bpp 10 pixel 24bpp packed 10 pixel 24bpp packed 21 pixel 24bpp packed 32 pixel 24bpp unpacked not used 0 table 45-7. big endian memory organization mem addr 0x3 0x2 0x1 0x0 bit313029282726252423222120191817161514131211109876543210 pixel 1bpp 0 1 2 345678910111213141516171819202122232425262728293031 pixel 2bpp 0123456789101112131415 pixel 4bpp 0 1 2 3 4 5 6 7 pixel 8bpp 0123 pixel 16bpp 01 pixel 24bpp packed 01 pixel 24bpp packed 12
1104 6438fCatarmC21-jun-10 at91sam9g45 45.6.2.5 palette this block is used to generate the pixel gray or color information in palletized configurations. the different modes with the palletized/non-palletized configuration can be found in table 45-9 . in these modes, 1, 2, 4 or 8 input bits index an entry in the lookup table. the corresponding entry in the lookup table contains the color or gray shade information for the pixel. pixel 24bpp packed 23 pixel 24bpp packed 45 pixel 24bpp unpacked not used 0 table 45-7. big endian memory organization (continued) mem addr 0x3 0x2 0x1 0x0 table 45-8. wince pixel memory organization mem addr 0x3 0x2 0x1 0x0 bit313029282726252423222120191817161514131211109876543210 pixel 1bpp 24 25 26 27 28 29 30 31 16 17 18 19 20 21 22 23 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 pixel 2bpp 12 13 14 15 8 9 10 11 4 5 6 7 0 1 3 3 pixel 4bpp 6 7 4 5 2 3 0 1 pixel 8bpp 3210 pixel 16bpp 10 pixel 24bpp packed 10 pixel 24bpp packed 21 pixel 24bpp packed 32 pixel 24bpp unpacked not used 0 table 45-9. palette configurations configuration palette distype pixelsize tft 1, 2, 4, 8 palletized tft 16, 24 non-palletized stn mono 1, 2 palletized
1105 6438fCatarmC21-jun-10 at91sam9g45 the lookup table can be accessed by the host in r/w mode to allow the host to program and check the values stored in the palette. it is mapped in the lcd controller configuration memory map. the lut is mapped as 16-bit half-words aligned at word boundaries, only word write access is allowed (the 16 msb of the bus are not used). for the detailed memory map, see table 45-16 on page 1125 . the lookup table contains 256 16 -bit wide entries. the 256 entries are chosen by the program- mer from the 2 16 possible combinations. for the structure of each lut entry, see table 45-10 . in stn monochrome, only the four most signifi cant bits of the red value are used (16 gray shades). in stn color, only the four most signi ficant bits of the blue, green and red value are used (4096 colors). in tft mode, all the bits in the blue, green and red values are used. the lcdd unused bits are tied to 0 when tft palletized c onfigurations are used (lcdd [18:16], lcdd[9: 8], lcdd[2:0]). 45.6.2.6 dithering the dithering block is used to generate the shades of gray or color when the lcd controller is used with an stn lcd module. it uses a time-based dithering algorithm and frame rate con- trol method. the frame rate control varies the duty cycle for which a given pixel is turned on, giving the dis- play an appearance of multiple shades. in order to reduce the flicker noise caused by turning on and off adjacent pixels at the same time, a time-based dithering algorithm is used to vary the pattern of adjacent pixels every frame. this algorithm is expressed in terms of dithering pattern registers (dp_i) and considers not only the pixel gray level number, but also its horizontal coordinate. stn mono 4 non-palletized stn color 1, 2, 4, 8 palletized stn color 16 non-palletized table 45-10. lookup table structure in the memory address data output [15:0] 00 red_value_0[4:0] green_value_0[5:0] blue_value_0[4:0] 01 red_value_1[4:0] green_value_1[5:0] blue_value_1[4:0] ... fe red_value_254[4:0] green_val ue_254[5:0] blue_value_254[4:0] ff red_value_255[4:0] green_val ue_255[5:0] blue_value_255[4:0] table 45-9. palette configurations (continued) configuration palette distype pixelsize
1106 6438fCatarmC21-jun-10 at91sam9g45 table 45-11 shows the correspondences between th e gray levels and the duty cycle. the duty cycles for gray levels 0 and 15 are 0 and 1, respectively. the same dp_i register can be used for the pairs for which the sum of duty cycles is 1 (e.g., 1/7 and 6/7). the dithering pattern for the first pair member is the inversion of the one for the second. the dp_i registers contain a series of 4-bit patterns. the (3-m) th bit of the pattern determines if a pixel with horizontal coordinate x = 4n + m (n is an integer and m ranges from 0 to 3) should be turned on or off in the current frame. the operation is shown by the examples below. consider the pixels a, b, c and d with the horizontal coordinates 4*n+0, 4*n+1, 4*n+2 and 4*n+3, respectively. the four pixels should be displayed in gray level 9 (duty cycle 3/5) so the register used is dp3_5 =1010 0101 1010 0101 1111. the output sequence obtained in the data output for monochrome mode is shown in table 45- 12 . table 45-11. dithering duty cycle gray level duty cycle pattern register 15 1 - 14 6/7 dp6_7 13 4/5 dp4_5 12 3/4 dp3_4 11 5/7 dp5_7 10 2/3 dp2_3 93/5dp3_5 84/7dp4_7 7 1/2 ~dp1_2 6 3/7 ~dp4_7 5 2/5 ~dp3_5 4 1/3 ~dp2_3 3 1/4 ~dp3_4 2 1/5 ~dp4_5 1 1/7 ~dp6_7 00- table 45-12. dithering algorithm for monochrome mode frame number pattern pixel a pixel b pixel c pixel d n1010onoffonoff n+1 0101 off on off on n+2 1010 on off on off n+3 0101 off on off on
1107 6438fCatarmC21-jun-10 at91sam9g45 consider now color display mode and two pixels p0 and p1 with the horizontal coordinates 4*n+0, and 4*n+1. a color pixel is composed of three components: {r, g, b}. pixel p0 will be dis- played sending the color components {r0, g0, b0 } to the display. pixe l p1 will be displayed sending the color components {r1, g1, b1}. suppose that the data read from memory and mapped to the lookup tables corresponds to shade level 10 for the three color components of both pixels, with the dithering pattern to apply to all of them being dp2_3 = 1101 1011 0110. table 45-13 shows the output sequence in the data output bus for single scan configurations. (in dual scan configuration, each panel data bus acts like in the equivalent single scan configuration.) n+41111onononon n+5 1010 on off on off n+6 0101 off on off on n+7 1010 on off on off ... ... ... ... ... ... table 45-12. dithering algorithm for monochrome mode (continued) frame number pattern pixel a pixel b pixel c pixel d table 45-13. dithering algorithm for color mode frame signal shadow level bit used dithering pattern 4-bit lcdd 8-bit lcdd output n red_data_0 1010 3 1101 lcdd[3] lcdd[7] r0 n green_data_0 1010 2 1101 lcdd[2] lcdd[6] g0 n blue_data_0 1010 1 1101 lcdd[1] lcdd[5] b0 n red_data_1 1010 0 1101 lcdd[0] lcdd[4] r1 n green_data_1 1010 3 1101 lcdd[3] lcdd[3] g1 n blue_data_1 1010 2 1101 lcdd[2] lcdd[2] b1 n+1 red_data_0 1010 3 1011 lcdd[3] lcdd[7] r0 n+1 green_data_0 1010 2 1011 lcdd[2] lcdd[6] g0 n+1 blue_data_0 1010 1 1011 lcdd[1] lcdd[5] b0 n+1 red_data_1 1010 0 1011 lcdd[0] lcdd[4] r1 n+1 green_data_1 1010 3 1011 lcdd[3] lcdd[3] g1 n+1 blue_data_1 1010 2 1011 lcdd[2] lcdd[2] b1 n+2 red_data_0 1010 3 0110 lcdd[3] lcdd[7] r0 n+2 green_data_0 1010 2 0110 lcdd[2] lcdd[6] g0 n+2 blue_data_0 1010 1 0110 lcdd[1] lcdd[5] b0 n+2 red_data_1 1010 0 0110 lcdd[0] lcdd[4] r1
1108 6438fCatarmC21-jun-10 at91sam9g45 note: ri = red pixel component on. gi = green pixel component on. bi = blue pixel component on. ri = red pixel component off. gi = green pixel component off. bi = blue pixel component off. 45.6.2.7 shifter the fifo, serializer, palette and dithering modules process one pixel at a time in monochrome mode and three sub-pixels at a time in color mode (r,g,b components). this module packs the data according to the output interfac e. this interface can be programmed in the distype, scanmod, and ifwidth fields of the ldccon3 register. the distype field selects between tft, stn mo nochrome and stn color display. the scan- mode field selects between single and dual sc an modes; in tft mode, only single scan is supported. the ifwidth field configures the width of the interface in stn mode: 4-bit (in single scan mode only), 8-bit and 16-bit (in dual scan mode only). for a more detailed description of the fields, see lcd controller (lcdc) user interface on page 1125 . for a more detailed description of the lcd interface, see lcd interface on page 1114 . 45.6.2.8 timegen the time generator block generates the control signals lcddotck, lcdhsync, lcdvsync, lcdden, and lcdmod, used by th e lcd module. this block is programmable in order to sup- port different types of lcd modules and obtain the output clock signals, which are derived from the lcdc core clock. the lcdmod signal provides an ac signal for the di splay. it is used by the lcd to alternate the polarity of the row and column voltages used to turn the pixels on and off. this prevents the liq- uid crystal from degradation. it can be configured to toggle every frame (bit mmode = 0 in lcdmval register) or to toggle every programmable number of lcdhsync pulses (bit mmode = 1, number of pulses defined in mval field of lcdmval register). figure 45-3 and figure 45-4 on page 1109 show the timing of lcdmod in both configurations. figure 45-3. full frame timing, mmode=1, mval=1 n+2 green_data_1 1010 3 0110 lcdd[3] lcdd[3] g1 n+2 blue_data_1 1010 2 0110 lcdd[2] lcdd[2] b1 table 45-13. dithering algorithm for color mode (continued) frame signal shadow level bit used dithering pattern 4-bit lcdd 8-bit lcdd output f lcd_mod f lcd_hsync 2 mval 1 + () ---------------------------------------- = lcdvsync lcdmod lcddotck line1 line2 line3 line4 line5
1109 6438fCatarmC21-jun-10 at91sam9g45 figure 45-4. full frame timing, mmode=0 the lcddotck signal is used to clock the data into the lcd drivers' shift register. the data is sent through lcdd[23:0] synchr onized by default with lcddotck falling edge (rising edge can be selected). the clkval field of lcdcon1 register controls the ra te of this signal. the divisor can also be bypassed with the by pass bit in the lcdcon1 register. in this case, the rate of lcddotck is equal to the frequency of the lcdc core clock. the minimum period of the lcd- dotck signal depends on the configuration. this information can be found in table 45-14 . the lcddotck signal has two different timings that are selected with the clkmod field of the lcdcon2 register: ? always active (used with tft lcd modules) ? active only when data is ava ilable (used with stn lcd modules) the lcdden signal indicates valid data in the lcd interface. after each horizontal line of data has been shifte d into the lcd, the lcdhsync is asserted to cause the line to be displayed on the panel. the following timing parameters can be configured: lcdvsync lcdmod lcddotck line1 line2 line3 line4 line5 table 45-14. minimum lcddotck period in lcdc core clock cycles configuration lcddotck period distype scan ifwidth tft 1 stn mono single 4 4 stn mono single 8 8 stn mono dual 8 8 stn mono dual 16 16 stn color single 4 2 stn color single 8 2 stn color dual 8 4 stn color dual 16 6 f lcddotck f lcdc_clock clkval 1 + -------------------------------- =
1110 6438fCatarmC21-jun-10 at91sam9g45 ? vertical to horizontal delay (vhdly): the delay between the falling edge of lcdvsync and the generation of lcdhsync is configurable in the vhdly field of the lcdtim1 register. the delay is equal to (vhdly+1) lcddotck cycles. ? horizontal pulse width (hpw): the lcdhsync pu lse width is configurable in hpw field of lcdtim2 register. the width is eq ual to (hpw + 1) lcddotck cycles. ? horizontal back porch (hbp): the delay bet ween the lcdhsync fallin g edge and the first lcddotck rising edge with valid data at the l cd interface is configurable in the hbp field of the lcdtim2 register. the delay is equal to (hbp+1) lcddotck cycles. ? horizontal front porch (hfp): the delay between end of valid data and the generation of the next lcdhsync is configurable in the hfp fiel d of the lcdtim2 register. the delay is equal to (hfp+vhdly+2) lcddotck cycles. there is a limitation in the minimum values of vhdly, hpw and hbp parameters imposed by the initial latency of the datapath. the total de lay in lcdc clock cycles must be higher than or equal to the latency column in table 45-4 on page 1102 . this limitation is given by the following formula: 45.6.2.9 equation 1 where: ? vhdly, hpw, hbp are the value of the fields of lcdtim1 and lcdtim2 registers ? pclk_period is the period of lcddotck signal measured in lcdc clock cycles ? dpath_latency is the datapath latency of the configuration, given in table 45-4 on page 1102 the lcdvsync is asserted once per frame. this signal is asserted to cause the lcd's line pointer to start over at the top of the display. the timing of this signal depends on the type of lcd: stn or tft lcd. in stn mode, the high phase corresponds to the complete first line of the frame. in stn mode, this signal is synchronized with the firs t active lcddotck rising edge in a line. in tft mode, the high phase of this signal starts at the beginning of the first line. the following timing parameters can be selected: ? vertical pulse width (vpw): lcdvsync pulse wid th is configurable in vpw field of the lcdtim1 register. the pulse width is equal to (vpw+1) lines. ? vertical back porch: number of inactive lines at the beginning of the frame is configurable in vbp field of lcdtim1 register. the number of inactive lines is e qual to vbp. this field should be programmed with 0 in stn mode. ? vertical front porch: number of inactive lines at the end of the frame is configurable in vfp field of lcdtim2 register. the number of inactive lines is equal to vfp. this field should be programmed with 0 in stn mode. there are two other parameters to configure in this module, the hozval and the lineval fields of the lcdfrmcfg: ? hozval configures the number of active l cddotck cycles in each line. the number of active cycles in each line is equal to (hozval+1) cycles. the minimum value of this parameter is 1. vhdly hpw hbp 3 +++ () pclk_period dpath_latency
1111 6438fCatarmC21-jun-10 at91sam9g45 ? lineval configures the number of active lines per frame. this number is equal to (lineval+1) lines. the minimum value of this parameter is 1. figure 45-5 , figure 45-6 and figure 45-7 show the timing of lcddotck, lcdden, lcdh- sync and lcdvsync signals: figure 45-5. stn panel timing, clkmod 0 lcdhsync lcdvsync lcdden lcddotck lcdd frame period vhdly+ hbp+1 hpw+1 hfp+vhdly+2 hozval+1 lcddotck lcdd 1 pclk 1/2 pclk 1/2 pclk line period lcdvsync lcdhsync lcdden
1112 6438fCatarmC21-jun-10 at91sam9g45 figure 45-6. tft panel timing, clkmod = 0, vpw = 2, vbp = 2, vfp = 1 figure 45-7. tft panel timing (line expanded view), clkmod = 1 usually the lcd_frm rate is ab out 70 hz to 75 hz. it is given by the following equation: where: ? hozval determines de number of lcddotck cycles per line ? lineval determines the nu mber of lcdhsync cycles per frame, according to the expressions shown below: in stn mode: vhdly+1 hbp+1 hpw+1 hfp+vhdly+2 hozval+1 lcddotck lcdd 1 pclk 1/2 pclk 1/2 pclk line period lcdvsync lcdhsync lcdden (vpw+1) lines lcdvsync lcddotck lcdd lcdden vhdly+1 lcdhsync vertical fron t porch = vfp lines vertical back porch = vbp lines frame period vhdly+1 hbp+1 hpw+1 hfp+vhdly+2 hozval+1 lcddotck lcdd 1 pclk 1/2 pclk 1/2 pclk line period lcdvsync lcdhsync lcdden 1 f lcdvsync --------------------------- - vhdly hpw hbp hozval hfp 4 () +++ ++ f lcddotck -------------------------------------------------------------------------------------------------------------------------- ?? ?? vbp lineval vfp 1 +++ () = hozval horizontal_display_size number_data_lines -------------------------------------------------------------- - 1 ? =
1113 6438fCatarmC21-jun-10 at91sam9g45 in monochrome mode, horizontal_display_size is equal to the number of horizontal pixels. the number_data_lines is equal to the number of bits of the interface in single scan mode; number_data_lines is equal to half the bits of the interface in dual scan mode. in color mode, horizontal_display_size equals three times the number of horizontal pixels. in tft mode: the frame rate equation is used first without considering the clock periods added at the end beginning or at the end of each line to determine, approximately, the lcddotck rate: with this value, the clkval is fixed, as well as the corresponding lcddotck rate. then select vhdly, hpw and hbp according to the type of lcd used and equation 1 on page 1110 . finally, the frame rate is adjusted to 70 hz - 75 hz with the hfp value: the line counting is controlled by the read-only field linecnt of lcdcon1 register. the line- cnt field decreases by one unit at each falling edge of lcdhsync. 45.6.2.10 display this block is used to configure the polarity of the data and control signals. the polarity of all clock signals can be configured by lcdcon2[12:8] register setting. this block also generates the lcd_pwr signal internally used to control the state of the lcd pins and to turn on and off by software the lcd module. it is also available on the lcdpwr pin. this signal is controlled by the pwrcon register and respects the number of frames configured in the guard_time field of pwrcon register (pwrcon[7:1]) between the write access to lcd_pwr field (pwrcon[0]) and the activation/deactivation of lcd_pwr signal. the minimum value for the guard_time field is one frame. this gives the dma controller enough time to fill the fifos before the start of data transfer to the lcd. 45.6.2.11 pwm this block generates the lcd co ntrast control signal (lcdcc) to make possible the control of the display's contrast by software. this is an 8- bit pwm (pulse width modulation) signal that can be converted to an analog voltage with a simple passive filter. lineval vertical_display_size 1 ? = hozval horizontal_display_size 1 ? = lineval vertical_display_size 1 ? = f lcd_pclk hozval 5 + () f lcd_vsync lineval 1 + () () = hfp f lcddotck 1 f lcdvsync lineval vbp vfp 1 +++ () ------------------------------------------------------------------------------------------------------------- - vhdly hpw hpb hozval 4 +++ + () ? =
1114 6438fCatarmC21-jun-10 at91sam9g45 the pwm module has a free-running counter whose value is compared against a compare reg- ister (constrast_val register). if the value in the counter is less than that in the register, the output brings the value of the polarity (pol) bit in the pwm control register: contrast_ctr. otherwise, the opposite value is output. thus, a periodic waveform with a pulse width propor- tional to the value in the compare register is generated. due to the comparison mechanism, the output pulse has a width between zero and 255 pwm counter cycles. thus by adding a simple passive filter outside the chip, an analog voltage between 0 and (255/256) vdd can be obtained (for the positive polarity case, or between (1/256) vdd and vdd for the negative polarity case). other voltage values can be obtained by adding active external circuitry. for pwm mode, the frequency of the counter can be adjusted to four different values using field ps of contrast_ctr register. 45.6.3 lcd interface the lcd controller interfaces with the lcd module through the lcd interface ( table 45-15 on page 1119 ). the controller supports the following interface configurations: 24-bit tft single scan, 16-bit stn dual scan mono (color), 8-bit stn dual (single) scan mono (color), 4-bit sin- gle scan mono (color). a 4-bit single scan stn display us es 4 parallel data lines to shift data to successive single hori- zontal lines one at a time until the entire frame has been shifted and transferred. the 4 lsb pins of lcd data bus (lcdd [3:0]) can be directly connected to the lcd driver; the 20 msb pins (lcdd [23:4]) are not used. an 8-bit single scan stn display uses 8 parallel data lines to shift data to successive single hor- izontal lines one at a time until the entire frame has been shifted and transferred. the 8 lsb pins of lcd data bus (lcdd [7:0]) can be directly connected to the lcd driver; the 16 msb pins (lcdd [23:8]) are not used. an 8-bit dual scan stn display uses two sets of 4 parallel data lines to shift data to successive upper and lower panel horizontal lines one at a time until the entire frame has been shifted and transferred. the bus lcdd[3:0] is connected to the upper panel data lines and the bus lcdd[7:4] is connected to the lower panel data lines. the re st of the lcd data bus lines (lcdd[23:8]) are not used. a 16-bit dual scan stn display uses two sets of 8 parallel data lines to shift data to successive upper and lower panel horizontal lines one at a time until the entire frame has been shifted and transferred. the bus lcdd[7:0] is connected to the upper panel data lines and the bus lcdd[15:8] is connected to the lower panel data lines. the rest of the lcd data bus lines (lcdd[23:16]) are not used. stn mono displays require one bit of image data per pixel. stn color displays require three bits (red, green and blue) of image data per pixel, resu lting in a horizontal shift register of length three times the number of pixels per horizontal line. this rgb or monochrome data is shifted to the lcd driver as consecutive bits via the parallel data lines. a tft single scan display uses up to 24 parallel data lines to shift data to successive horizontal lines one at a time until the entire frame has been shifted and transferred. the 24 data lines are divided in three bytes that define the color shade of each color component of each pixel. the lcdd bus is split as lcdd[23:16 ] for the blue component, lcdd [15:8] for the green component and lcdd[7:0] for the red component. if the lcd module has lower color resolution (fewer bits per color component), only the most significant bits of each component are used.
1115 6438fCatarmC21-jun-10 at91sam9g45 all these interfaces are shown in figure 45-8 to figure 45-12 . figure 45-8 on page 1115 shows the 24-bit single scan tft display timing; figure 45-9 on page 1115 shows the 4-bit single scan stn display timing for monochrome and color modes; figure 45-10 on page 1116 shows the 8- bit single scan stn display timing for monochrome and color modes; figure 45-11 on page 1117 shows the 8-bit dual scan stn display timing for monochrome and color modes; figure 45-12 on page 1118 shows the 16-bit dual scan stn display timing for monochrome and color modes. figure 45-8. tft timing (first line expanded view) figure 45-9. single scan monochrome and color 4-bit panel timing (first line expanded view) lcdvsync lcdden lcdhsync lcddotck lcdd [24:16] lcdd [15:8] lcdd [7:0] g0 b0 r0 g1 b1 r1 lcdvsync lcdden lcdhsync lcddotck lcdd [3] lcdd [2] lcdd [1] lcdd [0] p1 p0 p2 p3 p5 p4 p6 p7 lcdvsync lcdden lcdhsync lcddotck lcdd [3] lcdd [2] lcdd [1] lcdd [0] g0 r0 b0 r1 b1 g1 r2 g2
1116 6438fCatarmC21-jun-10 at91sam9g45 figure 45-10. single scan monochrome and color 8-bit panel timing (first line expanded view) lcdd [7] lcdd [6] lcdd [5] lcdd [4] p1 p0 p2 p3 p9 p8 p10 p11 lcdd [7] lcdd [6] lcdd [5] lcdd [4] g0 r0 b0 r1 r3 b2 g3 b3 lcdd [3] lcdd [2] lcdd [1] lcdd [0] p5 p4 p6 p7 p13 p12 p14 p15 lcdd [3] lcdd [2] lcdd [1] lcdd [0] b1 g1 r2 g2 g4 r4 b4 r5 lcdvsync lcdden lcdhsync lcddotck lcdvsync lcdden lcdhsync lcddotck
1117 6438fCatarmC21-jun-10 at91sam9g45 figure 45-11. dual scan monochrome and color 8-bit panel timing (first line expanded view) lcdd [7] lcdd [6] lcdd [5] lcdd [4] lp1 lp0 l2 l3 lp5 lp4 lp6 lp7 lcdd [7] lcdd [6] lcdd [5] lcdd [4] lg0 lr0 lb0 lr1 lb1 lg1 lr2 lg2 lcdd [3] lcdd [2] lcdd [1] lcdd [0] up1 up0 up2 up3 up5 up4 up6 up7 lcdd [3] lcdd [2] lcdd [1] lcdd [0] ug0 ur0 ub0 ur1 ub1 ug1 ur2 ug2 lower pane upper pane lower pane upper pane lcdvsync lcdden lcdhsync lcddotck lcdvsync lcdden lcdhsync lcddotck
1118 6438fCatarmC21-jun-10 at91sam9g45 figure 45-12. dual scan monochrome and color 16-bit pa nel timing (first line expanded view) lcdvsync lcdden lcdhsync lcddotc k lcdd [15] lcdd [ 14 ] lcdd [13] lcdd [12] lp1 lp0 lp2 lp3 lp9 lp8 lp10 lp11 lcdd [15] lcdd [ 14 ] lcdd [13] lcdd [12] lg0 lr0 lb0 lr1 lr3 lb2 lg3 lb3 lcdd [11] lcdd [ 10 ] lcdd [9] lcdd [8] lp5 lp4 lp6 lp7 lp13 lp12 lp14 lp15 lcdd [11] lcdd [ 10 ] lcdd [9] lcdd [8] lb1 lg1 lr2 lg2 lg4 lr4 lb4 lr5 lcdd [7] lcdd [ 6 ] lcdd [5] lcdd [4] ug0 ur0 ub0 ur1 ur3 ub2 ug3 ub3 lcdd [3] lcdd [ 2 ] lcdd [1] lcdd [0] ub1 ug1 ur2 ug2 ug4 ur4 ub4 ur5 lower panel upper panel lc dd [7] lcdd [ 6 ] lcdd [5] lcdd [4] up1 up0 up2 up3 up9 up8 up10 up11 lcdd [3] lcdd [ 2 ] lcdd [1] lcdd [0] up5 up4 up6 up7 up13 up12 up14 up15 lower panel upper panel lcdvsync lcdden lc dhsync lcddotc k
1119 6438fCatarmC21-jun-10 at91sam9g45 table 45-15. lcd signal multiplexing lcd data bus 4-bit stn single scan (mono, color) 8-bit stn single scan (mono, color) 8-bit stn dual scan (mono, color) 16-bit stn dual scan (mono, color) 24-bit tft 16-bit tft lcdd[23] lcd_blue7 lcd_blue4 lcdd[22] lcd_blue6 lcd_blue3 lcdd[21] lcd_blue5 lcd_blue2 lcdd[20] lcd_blue4 lcd_blue1 lcdd[19] lcd_blue3 lcd_blue0 lcdd[18] lcd_blue2 lcdd[17] lcd_blue1 lcdd[16] lcd_blue0 lcdd[15] lcdlp7 lcd_green7 lcd_green5 lcdd[14] lcdlp6 lcd_green6 lcd_green4 lcdd[13] lcdlp5 lcd_green5 lcd_green3 lcdd[12] lcdlp4 lcd_green4 lcd_green2 lcdd[11] lcdlp3 lcd_green3 lcd_green1 lcdd[10] lcdlp2 lcd_green2 lcd_green0 lcdd[9] lcdlp1 lcd_green1 lcdd[8] lcdlp0 lcd_green0 lcdd[7] lcd7 lcdlp3 lcdup7 lcd_red7 lcd_red4 lcdd[6] lcd6 lcdlp2 lcdup6 lcd_red6 lcd_red3 lcdd[5] lcd5 lcdlp1 lcdup5 lcd_red5 lcd_red2 lcdd[4] lcd4 lcdlp0 lcdup4 lcd_red4 lcd_red1 lcdd[3] lcd3 lcd3 lcdup3 lcdup3 lcd_red3 lcd_red0 lcdd[2] lcd2 lcd2 lcdup2 lcdup2 lcd_red2 lcdd[1] lcd1 lcd1 lcdup1 lcdup1 lcd_red1 lcdd[0] lcd0 lcd0 lcdup0 lcdup0 lcd_red0
1120 6438fCatarmC21-jun-10 at91sam9g45 45.7 interrupts the lcd controller generates six different irqs. a ll the irqs are synchronized with the internal lcd core clock. the irqs are: ? dma memory error irq. generated when the dma receives an error response from an ahb slave while it is doing a data transfer. ? fifo underflow irq. generated when the serializer tries to read a word from the fifo when the fifo is empty. ? fifo overwrite irq. generated when the dma co ntroller tries to write a word in the fifo while the fifo is full. ? dma end of frame irq. generated when the dma controller updates the frame base address pointers. this irq can be used to implement a double-buffer technique. for more information, see double-buffer technique on page 1122 . ? end of line irq. this irq is generated when the lineblank period of each line is reached and the dma controller is in inactive state. ? end of last line irq. this irq is generated when the lineblank period of the last line of the current frame is reached and the dma controller is in inactive state. each irq can be individually enabled, disabled or cleared, in the lcd_ier (interrupt enable register), lcd_idr (interrupt disable register ) and lcd_icr (interrupt clear register) regis- ters. the lcd_imr register contains the mask value for each irq source and the ldc_isr contains the status of each irq source. a more detailed description of these registers can be found in lcd controller (lcdc) user interface on page 1125 . 45.8 configuration sequence the dma controller starts to transfer image dat a when the lcdc core is activated (write to lcd_pwr field of pwrcon register). thus, t he user should config ure the lcdc core and configure and enable the dma controller prior to activation of the lcd controller. in addition, the image data to be shows should be available when the lcdc core is activated, regardless of the value programmed in the guard_time field of the pwrcon register. to disable the lcd controller, the user should disable the lcdc core and then disable the dma controller. the user should not enable lip again unt il the lcdc core is in idle state. this is checked by reading the lcd_busy bit in the pwrcon register. the initialization sequence that the user should follow to make the lcdc work is: ? create or copy the first image to show in the display buffer memory. ? if a palletized mode is used, create and store a palette in the internal lcd palette memory( see palette on page 1104. ? ? configure the lcd controller core without enabling it: C lcdcon1 register: program the c lkval and bypass fields: these fields control the pixel clock divisor that is used to generate the pixel clock lcddotck. the value to program depends on the lcd core clock and on the type and size of the lcd module used. there is a minimum value of the lcddotck clock period that depends on the lcd controller configuration, this minimum value can be found in table 45-14 on page 1109 . the equations that are used to calculate the value of the pixel clock divisor can be found at the end of the section timegen on page 1108
1121 6438fCatarmC21-jun-10 at91sam9g45 C lcdcon2 register: program its fields fo llowing their descriptions in the lcd controller user interface se ction below and considering the type of lcd module used and the desired working mode. consider that not all combinations are possible. C lcdtim1 and lcdtim2 registers: program their fields according to the datasheet of the lcd module used and with the help of the timegen section in page 10. note that some fields are not applicable to stn modules and must be programmed with 0 values. note also that there is a limitation on the minimum value of vhdly, hpw, hbp that depends on the configuration of the lcdc. C lcdfrmcfg register: program the dimensions of the lcd module used. C lcdfifo register: to program it, use the formula in section fifo on page 1102 C lcdmval register: its configuration depends on the lcd module used and should be tuned to improve the image quality in the display ( see timegen on page 1108. ) C dp1_2 to dp6_7 registers: they are only used for stn displays. they contain the dithering patterns used to generate gray shades or colors in these modules. they are loaded with recommended patterns at reset, so it is not necessary to write anything on them. they can be used to improve the image quality in the display by tuning the patterns in each application. C pwrcon register: this register controls the power-up sequence of the lcd, so take care to use it properly. do not enable the lcd (writing a 1 in lcd_pwr field) until the previous steps and the configuration of the dma have been finished. C contrast_ctr and contrast_val: use this registers to adjust the contrast of the display, when the lcdcc line is used. ? ? configure the dma controller. the user should configure the base address of the display buffer memory, the size of the ahb transaction and the size of the display image in memory. when the dma is configured the user should enable the dma. to do so the user should configure the following registers: C dmabaddr1 and dmabaddr2 registers: in single scan mode only dmabaddr1 register must be configured with the base address of the display buffer in memory. in dual scan mode dmabaddr1 should be co nfigured with the base address of the upper panel display buffer and dmabaddr2 should be configured with the base address of the lower panel display buffer. C dmafrmcfg register: program the frmsize field. note that in dual scan mode the vertical size to use in the calculation is that of each panel. respect to the brstln field, a recommended value is a 4-word burst. C dmacon register: once both the lcd cont roller core and the dma controller have been configured, enable the dma controller by writing a 1 to the dmaen field of this register. if using a dual scan module or the 2d addressing feature, do not forget to write the dmaupdt bit after every change to the set of dma configuration values. C dma2dcfg register: required only in 2d memory addressing mode (see 2d memory addressing on page 1122 ). ? finally, enable the lcd controller core by writing a 1 in the lcd_pwr field of the pwrcon register and do any other action that may be required to turn the lcd module on.
1122 6438fCatarmC21-jun-10 at91sam9g45 45.9 double-buffer technique the double-buffer technique is used to avoid flickering while the frame being displayed is updated. instead of using a single buffer, there are two different buffers, the backbuffer (back- ground buffer) and the primary buffer (the buffer being displayed). the host updates the backbuffer while the lcd controller is displaying the primary buffer. when the backbuffer has been updated the host updates the dma base address registers. when using a dual panel lcd module, both base address pointers should be updated in the same frame. there are two possibilities: ? check the dmafrmptx register to ensure that there is enough time to update the dma base address registers before the end of frame. ? update the frame base address registers when the end of frame irq is generated. once the host has updated the frame base address registers and the next dma end of frame irq arrives, the backbuffer and the primary buffer are swapped and the host can work with the new backbuffer. when using a dual-panel lcd module, both ba se address pointers should be updated in the same frame. in order to achieve this, the dm aupdt bit in dmacon register must be used to validate the new base address. 45.10 2d memory addressing the lcdc can be configured to work on a frame buffer larger than the actual screen size. by changing the values in a few registers, it is easy to move the displayed area along the frame buf- fer width and height. figure 45-13. frame buffer addressing in order to locate the displayed window within a larger frame buffer, the software must: ? program the dmabaddr1 (dmabaddr2) register (s) to make them point to the word containing the first pixel of the area of interest. ? program the pixeloff field of dma2dcfg register to specify the offset of this first pixel within the 32-bit memory word that contains it. displayed image frame buffer base word address & pixel offset line-to-line address increment
1123 6438fCatarmC21-jun-10 at91sam9g45 ? define the width of the complete frame buffer by programming in the field addrinc of dma2dcfg register the address increment between the last word of a line and the first word of the next line (in number of 32-bit words). ? enable the 2d addressing mode by writing the dma2den bit in dmacon register. if this bit is not activated, the values in the dma2dcfg register are not considered and the controller assumes that the displayed area occupies a continuous portion of the memory. the above configuration can be changed frame to frame, so the displayed window can be moved rapidly. note that the frmsize field of dmafrmcfg register must be updated with any movement of the displaying window. note also that the software must write bit dmaupdt in dmacon register after each configurat ion for it to be accepted by lcdc. note: in 24 bpp packed mode, the dma base address must point to a word containing a complete pixel (possible values of pixeloff are 0 and 8). this me ans that the horizontal origin of the displaying window must be a multiple of 4 pixels or a multiple of 4 pixels minus 1 ( x = 4n or x = 4n-1 , valid ori- gins are pixel 0,3,4,7,8,11,12, etc.).
1124 6438fCatarmC21-jun-10 at91sam9g45 45.11 register configuration guide program the pio controller to enable lcd signals. enable the lcd controller clock in the power manage ment controller. 45.11.1 stn mode example stn color(r,g,b) 320*240, 8-bit single scan, 70 frames/sec, master clock = 60 mhz data rate: 320*240*70*3/8 = 2.016 mhz hozval= ((3*320)/8) - 1 lineval= 240 -1 clkval = (60 mhz/2.016 mhz) - 1 = 29 lcdcon1= clkval << 12 lcdcon2 = littleendian | singlescan | stncolor | disp8bit| ps8bpp; lcdtim1 = 0; lcdtim2 = 10 | (10 << 21); lcdfrmcfg = (hozval << 21) | lineval; lcdmval = 0x80000004; dmafrmcfg = (7 << 24) + (320 * 240 * 8) / 32; 45.11.2 tft mode example this example is based on the nec tft color lcd module nl6448bc20-08 . tft 640*480, 16-bit single scan, 60 frames/sec , pixel clock frequency = [21mhz..29mhz] with a typical value = 25.175 mhz. the master clock must be (n + 1)*pixel clock frequency hozval = 640 - 1 lineval = 480 - 1 if master clock is 100 mhz clkval = (100 mhz/ 25.175 mhz) - 1= 3 vfp = (12 -1), vbp = (31-1), vpw = (2-1), vhdly= (2-1) hfp = (16-1), hbp = (48 -1), hpw= (96-1) lcdcon1= clkval << 12 lcdcon2 = littleendian | clkmod | in vert_clk | invert_line | invert_frm | ps16bpp | singlescan | tft lcdtim1 = vfp | (vbp << 8) | (vpw << 16) | (vhdly << 24) lcdtim2 = hbp | (hpw << 8) | (hfp << 21) lcdfrmcfg = (hozval << 21) | lineval lcdmval = 0 dmafrmcfg = (7 << 24) + (640 * 480* 16) / 32;
1125 6438fCatarmC21-jun-10 at91sam9g45 45.12 lcd controller (lcdc) user interface table 45-16. register mapping offset register name access reset 0x0 dma base address register 1 dmabaddr1 read-write 0x00000000 0x4 dma base address register 2 dmabaddr2 read-write 0x00000000 0x8 dma frame pointer register 1 dmafrmpt1 read-only 0x00000000 0xc dma frame pointer register 2 dmafrmpt2 read-only 0x00000000 0x10 dma frame address register 1 dmafrmadd1 read-only 0x00000000 0x14 dma frame address register 2 dmafrmadd2 read-only 0x00000000 0x18 dma frame configuration regi ster dmafrmcfg read-write 0x00000000 0x1c dma control register dmacon read-write 0x00000000 0x20 dma control register dma2dcfg read-write 0x00000000 0x800 lcd control register 1 lcdcon1 read-write 0x00002000 0x804 lcd control register 2 lcdcon2 read-write 0x00000000 0x808 lcd timing register 1 lcdtim1 read-write 0x00000000 0x80c lcd timing register 2 lcdtim2 read-write 0x00000000 0x810 lcd frame configuration register lcdfrmcfg read-write 0x00000000 0x814 lcd fifo register lcdfifo read-write 0x00000000 0x818 lcdmod toggle rate value register lcdmval read-write 0x00000000 0x81c dithering pattern dp1_2 dp1_2 read-write 0xa5 0x820 dithering pattern dp4_7 dp4_7 read-write 0x5af0fa5 0x824 dithering pattern dp3_5 dp3_5 read-write 0xa5a5f 0x828 dithering pattern dp2_3 dp2_3 read-write 0xa5f 0x82c dithering pattern dp5_7 dp5_7 read-write 0xfaf5fa5 0x830 dithering pattern dp3_4 dp3_4 read-write 0xfaf5 0x834 dithering pattern dp4_5 dp4_5 read-write 0xfaf5f 0x838 dithering pattern dp6_7 dp6_7 read-write 0xf5ffaff 0x83c power control register pwrcon read-write 0x0000000e 0x840 contrast control register contrast_ctr read-write 0x00000000 0x844 contrast value register contrast_val read-write 0x00000000 0x848 lcd interrupt enable register lcd_ier write-only 0x0 0x84c lcd interrupt disable register lcd_idr write-only 0x0 0x850 lcd interrupt mask register lcd_imr read-only 0x0 0x854 lcd interrupt status register lcd_isr read-only 0x0 0x858 lcd interrupt clear register lcd_icr write-only 0x0 0x860 lcd interrupt test register lcd_itr write-only 0 0x864 lcd interrupt raw status register lcd_irr read-only 0 0x8e4 write protection control register lcd_wpcr read-write 0
1126 6438fCatarmC21-jun-10 at91sam9g45 0x8e8 write protection status register lcd_wpsr read-only 0 0xc00 palette entry 0 lut entry 0 read-write 0xc04 palette entry 1 lut entry 1 read-write 0xc08 palette entry 2 lut entry 2 read-write 0xc0c palette entry 3 lut entry 3 read-write 0xffc palette entry 255 lut entry 255 read-write table 45-16. register mapping (continued) offset register name access reset
1127 6438fCatarmC21-jun-10 at91sam9g45 45.12.1 dma base address register 1 name: dmabaddr1 address: 0x00500000 access: read-write reset value: 0x00000000 ? baddr-u base address for the upper panel in dual scan mode. base address for the complete frame in single scan mode. if a dual scan configuration is selected in lcdcon2 register or bit dma2den in register dmacon is set, the bit dmaupdt in that same register must be written after writing an y new value to this field in or der to make the dma controller use this new value. 45.12.2 dma base address register 2 name: dmabaddr2 address: 0x00500004 access: read-write reset value: 0x00000000 ? baddr-l base address for the lower panel in dual scan mode only. if a dual scan configuration is selected in lcdcon2 register or bit dma2den in register dmacon is set, the bit dmaupdt in that same register must be written after writing an y new value to this field in or der to make the dma controller use this new value. 31 30 29 28 27 26 25 24 baddr-u 23 22 21 20 19 18 17 16 baddr-u 15 14 13 12 11 10 9 8 baddr-u 76543210 baddr-u 0 0 31 30 29 28 27 26 25 24 baddr-l 23 22 21 20 19 18 17 16 baddr-l 15 14 13 12 11 10 9 8 baddr-l 76543210 baddr-l
1128 6438fCatarmC21-jun-10 at91sam9g45 45.12.3 dma frame pointer register 1 name: dmafrmpt1 address: 0x00500008 access: read-only reset value: 0x00000000 ?frmpt-u current value of frame pointer for the upper panel in dual scan mode. current value of frame pointer for the complete frame in single scan mode. down count from frmsize to 0. note: this register is read-only and contains the current value of the frame pointer (number of wo rds to the end of the frame). it can be used as an estimation of the number of words transferred from memory for the current frame. 45.12.4 dma frame pointer register 2 name: dmafrmpt2 address: 0x0050000c access: read-only reset value : 0x00000000 ?frmpt-l current value of frame pointer for the lower panel in dual scan mode only. down count from frmsize to 0. note: this register is read-only and contains the current value of the frame pointer (number of wo rds to the end of the frame). it can be used as an estimation of the number of words transferred from memory for the current frame. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 Cfrmpt-u 15 14 13 12 11 10 9 8 frmpt-u 76543210 frmpt-u 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 -frmpt-l 15 14 13 12 11 10 9 8 frmpt-l 76543210 frmpt-l
1129 6438fCatarmC21-jun-10 at91sam9g45 45.12.5 dma frame address register 1 name: dmafrmadd1 address: 0x00500010 access: read-only reset value: 0x00000000 ? frmadd-u current value of frame address for the upper panel in dual scan mode. current value of frame address for the complete frame in single scan. note: this register is read-only and contains the current val ue of the last dma transaction in the bus for the panel/frame. 45.12.6 dma frame address register 2 name: dmafrmadd2 address: 0x00500014 access: read-only reset value: 0x00000000 ? frmadd-l current value of frame address for the lower panel in single scan mode only. note: this register is read-only and contains the current va lue of the last dma transaction in the bus for the panel. 31 30 29 28 27 26 25 24 frmadd-u 23 22 21 20 19 18 17 16 frmadd-u 15 14 13 12 11 10 9 8 frmadd-u 76543210 frmadd-u 31 30 29 28 27 26 25 24 frmadd-l 23 22 21 20 19 18 17 16 frmadd-l 15 14 13 12 11 10 9 8 frmadd-l 76543210 frmadd-l
1130 6438fCatarmC21-jun-10 at91sam9g45 45.12.7 dma frame c onfiguration register name: dmafrmcfg address: 0x00500018 access: read-write reset value: 0x00000000 ? frmsize: frame size in single scan mode, this is the frame size in words. in dual scan mode, this is the size of each panel. if a dual scan configuration is selected in lcdcon2 register or bit dma2den in register dmacon is set, the bit dmaupdt in that same register must be written after writing an y new value to this field in or der to make the dma controller use this new value. ? brstln: burst length in words program with the desired burst length - 1 31 30 29 28 27 26 25 24 Cbrstln 23 22 21 20 19 18 17 16 Cfrmsize 15 14 13 12 11 10 9 8 frmsize 76543210 frmsize
1131 6438fCatarmC21-jun-10 at91sam9g45 45.12.8 dma control register name: dmacon address: 0x0050001c access: read-write reset value: 0x00000000 ? dmaen: dma enable 0: dma is disabled. 1: dma is enabled. ? dmarst: dma reset (write-only) 0: no effect. 1: reset dma module. dma module should be reset only when disabled and in idle state. ? dmabusy: dma busy 0: dma module is idle. 1: dma module is busy (doing a transaction on the ahb bus). ? dmaupdt: dma configuration update 0: no effect 1: update dma configuration . used for simultaneous updating of dma parameters in dual scan mode or when using 2d addressing. the values written in the registers dmabaddr1, dmabaddr2 and dma2dcfg, and in the field frmsize of register dmafrmcfg, are accepted by the dma controller and are applied at the next frame. this bit is used only if a dual scan configuration is selected (bit scanmod of lcdcon2 register) or 2d addressing is enabled (bit dma2den in this register). otherwise, the lcd controller accepts immediately the values written in the registers referred to above. ? dma2den: dma 2d addressing enable 0: 2d addressing is disabled (values in register dma2dcfg are dont care). 1: 2d addressing is enabled. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C C C dma2den dmaupdt dmabusy dmarst dmaen
1132 6438fCatarmC21-jun-10 at91sam9g45 45.12.9 lcd dma 2d addressing register name: dma2dcfg address: 0x00500020 access: read-write reset value: 0x00000000 ? addrinc: dma 2d addressing address increment when 2-d dma addressing is enabled (bit dma2den is set in register dmacon), th is field specifies the number of bytes that the dma controller must jump between screen lines. itb must be programmed as: [({address of first 32-bit word in a screen line} - {address of last 32-bit word in previous line})]. in other words, it is equal to 4*[number of 32-bit words occu- pied by each line in the complete frame buffer minus the number of 32-bit words occupied by each displayed line]. bit dmaupdt in register dmacon must be writ ten after writing any new value to this field in order to make the dma control- ler use this new value. ? pixeloff: dam2d addressing pixel offset when 2d dma addressing is enabled (bit dma2den is set in register dmacon), this field specifies the offset of the first pixel in each line within th e memory word that contains this pixel. the offset is specified in number of bits in the range 0-31 , so for example a value of 4 indicates that the first pixel in th e screen starts at bit 4 of the 32-bit word pointed by register dmabaddr1. bits 0 to 3 of that word are not used. this example is valid for little end ian memory organization. when using big endian memory organization, this offset is considered from bit 31 dow nwards, or equivalently, a given value of this field always selects the pixel in the same relative position within the word, independently of the memory ordering con- figuration. bit dmaupdt in register dmacon must be written a fter writing any new value to this field in order to make the dma controller use this new value. 31 30 29 28 27 26 25 24 CCC pixeloff 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 addrinc 76543210 addrinc
1133 6438fCatarmC21-jun-10 at91sam9g45 45.12.10 lcd control register 1 name: lcdcon1 address: 0x00500800 access: read-write, except linecnt: read-only reset value: 0x00002000 ? bypass: bypass lcddotck divider 0: the divider is not bypassed. lcddotck frequency defined by the clkval field. 1: the lcddotck divider is bypassed. lcddotck frequency is equal to the lcdc clock frequency. ? clkval: clock divider 9-bit divider for pixel clock (lcddotck) frequency. ? linecnt: line counter (read-only) current value of 11-bit line counter. down count from lineval to 0. 31 30 29 28 27 26 25 24 linecnt 23 22 21 20 19 18 17 16 linecnt clkval 15 14 13 12 11 10 9 8 clkval CCCC 76543210 CCCCCCCbypass pixel_clock system_clock clkval ( 1 ) + ? =
1134 6438fCatarmC21-jun-10 at91sam9g45 45.12.11 lcd control register 2 name: lcdcon2 address: 0x00500804 access: read-write reset value: 0x0000000 ? distype: display type ? scanmod: scan mode 0: single scan 1: dual scan ? ifwidth: interface width (stn) 31 30 29 28 27 26 25 24 memor CCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 clkmod C C invdval invclk invline invframe invvd 76543210 pixelsize ifwidth scanmod distype distype 0 0 stn monochrome 0 1 stn color 10tft 11reserved ifwidth 0 0 4-bit (only valid in single scan stn mono or color) 0 1 8-bit (only valid in stn mono or color) 1 0 16-bit (only valid in dual scan stn mono or color) 11reserved
1135 6438fCatarmC21-jun-10 at91sam9g45 ? pixelsize: bits per pixel ? invvd: lcdd polarity 0: normal 1: inverted ? invframe: lcdvsync polarity 0: normal (active high) 1: inverted (active low) ? invline: lcdhsync polarity 0: normal (active high) 1: inverted (active low) ? invclk: lcddotck polarity 0: normal (lcdd fetched at lcddotck falling edge) 1: inverted (lcdd fetched at lcddotck rising edge) ? invdval: lcdden polarity 0: normal (active high) 1: inverted (active low) ? clkmod: lcddotck mode 0: lcddotck only active during active display period 1: lcddotck always active ? memor: memory ordering format 00: big endian 10: little endian 11: wince format pixelsize 0 0 0 1 bit per pixel 0 0 1 2 bits per pixel 0 1 0 4 bits per pixel 0 1 1 8 bits per pixel 1 0 0 16 bits per pixel 1 0 1 24 bits per pixel, packed (only valid in tft mode) 1 1 0 24 bits per pixel, unpacked (only valid in tft mode) 1 1 1 reserved
1136 6438fCatarmC21-jun-10 at91sam9g45 45.12.12 lcd timing configuration register 1 name: lcdtim1 address: 0x00500808 access: read-write reset value: 0x0000000 ? vfp: vertical front porch in tft mode, these bits equal the number of idle lines at the end of the frame. in stn mode, these bits should be set to 0. ?vbp: vertical back porch in tft mode, these bits equal the number of idle lines at the beginning of the frame. in stn mode, these bits should be set to 0. ? vpw: vertical synchronization pulse width in tft mode, these bits equal the vertical synchronization pulse width, given in number of lines. lcdvsync width is equal to (vpw+1) lines. in stn mode, these bits should be set to 0. ? vhdly: vertical to horizontal delay in tft mode, this is the delay between lcdvsync rising or fallin g edge and lcdhsync ri sing edge. delay is (vhdly+1) lcddotck cycles. bit 31 must be written to 1. in stn mode, these bits should be set to 0. 31 30 29 28 27 26 25 24 1CCC vhdly 23 22 21 20 19 18 17 16 CC vpw 15 14 13 12 11 10 9 8 vbp 76543210 vfp
1137 6438fCatarmC21-jun-10 at91sam9g45 45.12.13 lcd timing configuration register 2 name: lcdtim2 address: 0x0050080c access: read-write reset value: 0x0000000 ? hbp: horizontal back porch number of idle lcddotck cycles at the beginning of the line. idle period is (hbp+1) lcddotck cycles. ? hpw: horizontal synch ronization pulse width width of the lcdhsync pulse, given in lcddotck cycles. width is (hpw+1) lcddotck cycles. ? hfp: horizontal front porch number of idle lcddotck cycles at the end of the line. idle period is (hfp+1) lcddotck cycles. 31 30 29 28 27 26 25 24 hfp 23 22 21 20 19 18 17 16 hfp CCCCC 15 14 13 12 11 10 9 8 CC hpw 76543210 hbp
1138 6438fCatarmC21-jun-10 at91sam9g45 45.12.14 lcd frame configuration register name: lcdfrmcfg address: 0x00500810 access: read-write reset value: 0x0000000 ? lineval: vertical size of lcd module in single scan mode: vertical size of lcd module, in pixels, minus 1 in dual scan mode: vertical display size of each lcd panel, in pixels, minus 1 ? linesize: horizontal size of lcd module, in pixels, minus 1 31 30 29 28 27 26 25 24 linesize 23 22 21 20 19 18 17 16 linesize CCCCC 15 14 13 12 11 10 9 8 CCCCC lineval 76543210 lineval
1139 6438fCatarmC21-jun-10 at91sam9g45 45.12.15 lcd fifo register name: lcdfifo address: 0x00500814 access: read-write reset value: 0x0000000 ? fifoth: fifo threshold must be programmed with: fifoth (in words) = 512 - (2 x dma_burst_length + 3) where: ? 512 is the effective size of the fifo in words. it is the total fifo memory size in single scan mode and half that size in dual scan mode. ? dma_burst_length is the burst length of the transfers made by the dma (in words). refer to brstln: burst length in words on page 1130 . 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 fifoth 76543210 fifoth
1140 6438fCatarmC21-jun-10 at91sam9g45 45.12.16 lcdmod toggle rate value register name: lcdmval access: read-write reset value: 0x00000000 ? mval: lcdmod toggle rate value lcdmod toggle rate if mmode = 1. t oggle rate is mval + 1 line periods. ? mmode: lcdmod toggle rate select 0: each frame 1: rate defined by mval 31 30 29 28 27 26 25 24 mmodeCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 mval
1141 6438fCatarmC21-jun-10 at91sam9g45 45.12.17 dithering pattern dp1_2 register name: dp1_2 address: 0x0050081c access: read-write reset value: 0xa5 ? dp1_2: pattern value for ? duty cycle 45.12.18 dithering pattern dp4_7 register name: dp4_7 address: 0x00500820 access: read-write reset value: 0x5af0fa5 ? dp4_7: pattern value for 4/7 duty cycle 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 dp1_2 31 30 29 28 27 26 25 24 CCCC dp4_7 23 22 21 20 19 18 17 16 dp4_7 15 14 13 12 11 10 9 8 dp4_7 76543210 dp4_7
1142 6438fCatarmC21-jun-10 at91sam9g45 45.12.19 dithering pattern dp3_5 register name: dp3_5 address: 0x00500824 access: read-write reset value: 0xa5a5f ? dp3_5: pattern value for 3/5 duty cycle 45.12.20 dithering pattern dp2_3 register name: dp2_3: dithering pattern dp2_3 register address: 0x00500828 access: read-write reset value: 0xa5f ? dp2_3: pattern value for 2/3 duty cycle 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCC dp3_5 15 14 13 12 11 10 9 8 dp3_5 76543210 dp3_5 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCC dp2_3 76543210 dp2_3
1143 6438fCatarmC21-jun-10 at91sam9g45 45.12.21 dithering pattern dp5_7 register name: dp5_7: address: 0x0050082c access: read-write reset value: 0xfaf5fa5 ? dp5_7: pattern value for 5/7 duty cycle 45.12.22 dithering pattern dp3_4 register name: dp3_4 address: 0x00500830 access: read-write reset value: 0xfaf5 ? dp3_4: pattern value for 3/4 duty cycle 31 30 29 28 27 26 25 24 CCCC dp5_7 23 22 21 20 19 18 17 16 dp5_7 15 14 13 12 11 10 9 8 dp5_7 76543210 dp5_7 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 dp3_4 76543210 dp3_4
1144 6438fCatarmC21-jun-10 at91sam9g45 45.12.23 dithering pattern dp4_5 register name: dp4_5 address: 0x00500834 access: read-write reset value: 0xfaf5f ? dp4_5: pattern value for 4/5 duty cycle 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCC dp4_5 15 14 13 12 11 10 9 8 dp4_5 76543210 dp4_5
1145 6438fCatarmC21-jun-10 at91sam9g45 45.12.24 dithering pattern dp6_7 register name: dp6_7 address: 0x00500838 access: read-write reset value: 0xf5ffaff ? dp6_7: pattern value for 6/7 duty cycle 45.12.25 power control register name: pwrcon address: 0x0050083c access: read-write reset value: 0x0000000e ? lcd_pwr: lcd module power control 0 = lcd_pwr signal is low, other lcd_* signals are low. 0->1 = lcd_* signals activated, lcd_pwr is set high with the delay of guard_time frame periods. 1 = lcd_pwr signal is high, ot her lcd_* signals are active. 1->0 = lcd_pwr signal is low, other lcd_* signals are active, but are set low after guard_time frame periods. ? guard_time delay in frame periods between applying control signals to the lcd module and setting lcd_pwr high, and between set- ting lcd_pwr low and removing control signals from lcd module ? lcd_busy read-only field. if 1, it indicates that the lcd is busy (act ive and displaying data, in power on sequence or in power off sequence). 31 30 29 28 27 26 25 24 CCCC dp6_7 23 22 21 20 19 18 17 16 dp6_7 15 14 13 12 11 10 9 8 dp6_7 76543210 dp6_7 31 30 29 28 27 26 25 24 lcd_busyCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 guard_time lcd_pwr
1146 6438fCatarmC21-jun-10 at91sam9g45 45.12.26 contrast control register name: contrast_ctr address: 0x00500840 access: read-write reset value: 0x00000000 ?ps this 2-bit value selects the configuration of a counter prescaler. the meaning of each combination is as follows: ?pol this bit defines the polarity of the output. if 1, the ou tput pulses are high level (the out put will be high whenever the value in the counter is less than the value in the compare register constrast_val). if 0, the output pulses are low level. ?ena when 1, this bit enables the operation of the pwm generator. when 0, the pwm counter is stopped. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CCCCenapol ps ps 0 0 the counter advances at a rate of fcounter = flcdc_clock. 0 1 the counter advances at a rate of fcounter = flcdc_clock/2. 1 0 the counter advances at a rate of fcounter = flcdc_clock/4. 1 1 the counter advances at a rate of fcounter = flcdc_clock/8.
1147 6438fCatarmC21-jun-10 at91sam9g45 45.12.27 contrast value register name: constrast_val access: read-write reset value: 0x00000000 ?cval pwm compare value. used to adjust the analog value obtained after an external filter to control the contrast of the display. 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 cval
1148 6438fCatarmC21-jun-10 at91sam9g45 45.12.28 lcd interrupt enable register name: lcd_ier address: 0x00500848 access: write-only reset value: 0x0 ? lnie: line interrupt enable 0: no effect 1: enable each line interrupt ? lstlnie: last line interrupt enable 0: no effect 1: enable last line interrupt ? eofie: dma end of frame interrupt enable 0: no effect 1: enable end of frame interrupt ? uflwie: fifo underflow interrupt enable 0: no effect 1: enable fifo u nderflow interrupt ? owrie: fifo overwrite interrupt enable 0: no effect 1: enable fifo overwrite interrupt ? merie: dma memory error interrupt enable 0: no effect 1: enable dma memory error interrupt 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C merie owrie uflwie - eofie lstlnie lnie
1149 6438fCatarmC21-jun-10 at91sam9g45 45.12.29 lcd interrupt disable register name: lcd_idr address: 0x0050084c access: write-only reset value: 0x0 ? lnid: line interrupt disable 0: no effect 1: disable each line interrupt ? lstlnid: last line interrupt disable 0: no effect 1: disable last line interrupt ? eofid: dma end of frame interrupt disable 0: no effect 1: disable end of frame interrupt ? uflwid: fifo underflow interrupt disable 0: no effect 1: disable fifo un derflow interrupt ? owrid: fifo overwrite interrupt disable 0: no effect 1: disable fifo overwrite interrupt ? merid: dma memory error interrupt disable 0: no effect 1: disable dma memo ry error interrupt 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C merid owrid uflwid C eofid lstlnid lnid
1150 6438fCatarmC21-jun-10 at91sam9g45 45.12.30 lcd interrupt mask register name: lcd_imr address: 0x00500850 access: read-only reset value: 0x0 ? lnim: line interrupt mask 0: line interrupt disabled 1: line interrupt enabled ? lstlnim: last line interrupt mask 0: last line interrupt disabled 1: last line interrupt enabled ? eofim: dma end of frame interrupt mask 0: end of frame interrupt disabled 1: end of frame interrupt enabled ? uflwim: fifo underflow interrupt mask 0: fifo underflow interrupt disabled 1: fifo underflow interrupt enabled ? owrim: fifo overwrite interrupt mask 0: fifo overwrite interrupt disabled 1: fifo overwrite interrupt enabled ? merim: dma memory error interrupt mask 0: dma memory error interrupt disabled 1: dma memory error interrupt enabled 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 CmerimowrimuflwimC eofim lstlnim lnim
1151 6438fCatarmC21-jun-10 at91sam9g45 45.12.31 lcd interrupt status register name: lcd_isr address: 0x00500854 access: read-only reset value: 0x0 ? lnis: line interrupt status 0: line interrupt not active 1: line interrupt active ? lstlnis: last line interrupt status 0: last line interrupt not active 1: last line interrupt active ? eofis: dma end of frame interrupt status 0: end of frame interrupt not active 1: end of frame interrupt active ? uflwis: fifo underflow interrupt status 0: fifo underflow interrupt not active 1: fifo underflow interrupt active ? owris: fifo overwrite interrupt status 0: fifo overwrite interrupt not active 1: fifo overwrite interrupt active ? meris: dma memory error interrupt status 0: dma memory error interrupt not active 1: dma memory error interrupt active 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C meris owris uflwis C eofis lstlnis lnis
1152 6438fCatarmC21-jun-10 at91sam9g45 45.12.32 lcd interrupt clear register name: lcd_icr address: 0x00500858 access: write-only reset value: 0x0 ? lnic: line interrupt clear 0: no effect 1: clear each line interrupt ? lstlnic: last line interrupt clear 0: no effect 1: clear last line interrupt ? eofic: dma end of frame interrupt clear 0: no effect 1: clear end of frame interrupt ? uflwic: fifo underflow interrupt clear 0: no effect 1: clear fifo underflow interrupt ? owric: fifo overwrite interrupt clear 0: no effect 1: clear fifo overwrite interrupt ? meric: dma memory error interrupt clear 0: no effect 1: clear dma memory error interrupt 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C meric owric uflwic C eofic lstlnic lnic
1153 6438fCatarmC21-jun-10 at91sam9g45 45.12.33 lcd interrupt test register name: lcd_itr address: 0x00500860 access: write-only reset value: 0x0 ? lnit: line interrupt test 0: no effect 1: set each line interrupt ? lstlnit: last line interrupt test 0: no effect 1: set last line interrupt ? eofit: dma end of frame interrupt test 0: no effect 1: set end of frame interrupt ? uflwit: fifo underflow interrupt test 0: no effect 1: set fifo underflow interrupt ? owrit: fifo overwrite interrupt test 0: no effect 1: set fifo overwrite interrupt ? merit: dma memory error interrupt test 0: no effect 1: set dma memory error interrupt 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C merit owrit uflwit C eofit lstlnit lnit
1154 6438fCatarmC21-jun-10 at91sam9g45 45.12.34 lcd interrupt raw status register name: lcd_irr address: 0x00500864 access: write-only reset value: 0x0 ? lnir: line interrupt raw status 0: no effect 1: line interrupt condition present ? lstlnir: last line interrupt raw status 0: no effect 1: last line interrupt condition present ? eofir: dma end of frame interrupt raw status 0: no effect 1: end of frame interrupt condition present ? uflwir: fifo underflow interrupt raw status 0: no effect 1: fifo underflow interrupt condition present ? owrir: fifo overwrite interrupt raw status 0: no effect 1: fifo overwrite interrupt condition present ? merir: dma memory error interrupt raw status 0: no effect 1: dma memory error interrupt condition present 31 30 29 28 27 26 25 24 CCCCCCCC 23 22 21 20 19 18 17 16 CCCCCCCC 15 14 13 12 11 10 9 8 CCCCCCCC 76543210 C merir owrir uflwir C eofir lstlnir lnir
1155 6438fCatarmC21-jun-10 at91sam9g45 45.12.35 lcd write protect mode register register name: lcd_wpmr access type: read-write ? wpen: write protect enable 0 = disables the write protect if wpkey corresponds to 0x4c4344 ("lcd" in ascii). 1 = enables the write protect if wpkey corresponds to0x4c4344 ("lcd" in ascii). protects the registers: ? lcd control register 1 on page 1133 ? lcd control register 2 on page 1134 ? lcd timing configuration register 1 on page 1136 ? lcd timing configuration register 2 on page 1137 ? lcd frame configuration register on page 1138 ? lcd fifo register on page 1139 ? lcdmod toggle rate value register on page 1140 ? dithering pattern dp1_2 register on page 1141 ? dithering pattern dp4_7 register on page 1141 ? dithering pattern dp3_5 register on page 1142 ? dithering pattern dp2_3 register on page 1142 ? dithering pattern dp5_7 register on page 1143 ? dithering pattern dp3_4 register on page 1143 ? dithering pattern dp4_5 register on page 1144 ? dithering pattern dp6_7 register on page 1145 ? wpkey: write protect key should be written at value 0x4c4344 ("lcd" in ascii). writing any other value in this field aborts the write operation of the wpen bit. always reads as 0. 31 30 29 28 27 26 25 24 wpkey 23 22 21 20 19 18 17 16 wpkey 15 14 13 12 11 10 9 8 wpkey 76543210 wpen
1156 6438fCatarmC21-jun-10 at91sam9g45 45.12.36 lcd write protect status register register name: lcd_wpsr address: 0x005008e8 access type: read-only ? wpvs: write protect enable 0 = no write protect violation has occurred since the last read of the lcd_wpsr register. 1 = a write protect violation occurred since the last read of the lcd_wpsr register. if th is violation is an unauthorized attempt to write a protected register, the associated violation is reported into field wpvsrc. ? wpvsrc: write protect violation source when wpvs is active, this field indicates the write-protected register (t hrough address offset or code) in which a write access has been attempted. note: reading lcd_wpsr automatically clears all fields 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 wpvsrc 15 14 13 12 11 10 9 8 wpvsrc 76543210 wpvs
1157 6438fCatarmC21-jun-10 at91sam9g45 46. at91sam9g45 electric al characteristics 46.1 absolute maximum ratings 46.2 dc characteristics the following characteristics are applicable to the operating temperature range: t a = -40c to +85c, unless otherwise specified. table 46-1. absolute maximum ratings* operating temperature (industrial)................-40 c to + 85 c *notice: stresses beyond those listed under absolute maximum ratings may cause permanent damage to the device. this is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational se ctions of this specification is not implied. exposure to absolute maximum rating conditions for extended periods may affect device reli- ability. junction temperature...................................................125c storage temperature...................................-60c to + 150c voltage on input pins with respect to ground......-0.3v to vddio+0.3v(+ 4v max) maximum operating voltage (vddcore, vddplla, vddutmic, vddpllutmi)....1.2v (vddiom0).....................................................................2.0v (vddiom1, vddiopx, vddutmii, vddosc, vddana and vddbu)....................................................4.0v total dc output current on all i/o lines.....................350 ma table 46-2. dc characteristics symbol parameter conditions min typ max units v vddcore dc supply core 0.9 1.0 1.1 v v vddcorerip vddcore ripple 20 mvrms v vddutmic dc supply udphs and uhphs utmi+ core 0.9 1.0 1.1 v v vddutmii dc supply udphs and uhphs utmi+ interface 3.0 3.3 3.6 v v vddbu dc supply backup 1.8 3.6 v v vddburip vddbu ripple 30 mvrms v vddplla dc supply plla 0.9 1.0 1.1 v v vddpllarip vddplla ripple 10 mvrms v vddpllutmi dc supply pllutmi 0.9 1.0 1.1 v v vddpllutmirip vddpllutmi ripple 10 mvrms v vddosc dc supply oscillator 1.65 3.6 v v vddoscrip vddosc ripple 30 mvrms v vddiom0 dc supply ddr i/os 1.65 1.8 1.95 v v vddiom1 dc supply ebi i/os 1.65/3.0 1.8/3.3 1.95/3.6 v
1158 6438fCatarmC21-jun-10 at91sam9g45 v vddiop0 dc supply peripheral i/os 1.65 3.6 v v vddiop1 dc supply peripheral i/os 1.65 3.6 v v vddiop2 dc supply isi 1.65 3.6 v v vddana dc supply analog 3.0 3.3 3.6 v v il input low-level voltage v vddio from 3.0v to 3.6v -0.3 0.8 v v vddio from 1.65v to 1.95v -0.3 0.3 x v vddio v v ih input high-level voltage v vddio from 3.0v to 3.6v 2 v vddio + 0.3 v v vddio from 1.65v to 1.95v 0.7 x v vddio v vddio + 0.3 v v ol output low-level voltage i o max, v vddio from 3.0v to 3.6v 0.4 v cmos (i o <0.3 ma), v vddio from 1.65v to 1.95v 0.1 v ttl (i o max), v vddio from 1.65v to 1.95v 0.4 v v oh output high-level voltage i o max, v vddio from 3.0v to 3.6v v vddio - 0.4 v cmos (i o <0.3 ma), v vddio from 1.65v to 1.95v v vddio - 0.1 v ttl (i o max), v vddio from 1.65v to 1.95v v vddio - 0.4 v v t- schmitt trigger negative going threshold voltage i o max, v vddio from 3.0v to 3.6v 0.8 1.1 v ttl (i o max), v vddio from 1.65v to 1.95v 0.3 x v vddio v v t+ schmitt trigger positive going threshold voltage i o max, v vddio from 3.0v to 3.6v 1.6 2.0 v ttl (i o max), v vddio from 1.65v to 1.95v 0.3 x v vddio v v hys schmitt trigger hysteresis v vddio from 3.0v to 3.6v 0.5 0.75 v v vddio from 1.65v to 1.95v 0.28 0.6 v r pullup pull-up resistance pa0-pa31 pb0-pb31 pd0-pd31 pe0- pe31 ntrst and nrst 40 75 190 kohms pc0-pc31 v vddiom1 in 1.8v range 240 1000 pc0-pc31 v vddiom1 in 3.3v range 120 350 i o output current pa0-pa31 pb0-pb31 pd0-pd31 pe0- pe31 8 ma pc0-pc31 v vddiom1 in 1.8v range 2 pc0-pc31 v vddiom1 in 3.3v range 4 table 46-2. dc characteristics (continued)
1159 6438fCatarmC21-jun-10 at91sam9g45 46.3 power consumption ? typical power consumption of plls , slow clock and main oscillator. ? power consumption of power supply in four different modes: active, idle, ultra low-power and backup. ? power consumption by peripheral: calculated as the difference in current measurement after having enabled then disabled the corresponding clock. 46.3.1 power consumption versus modes the values in table 46-3 and table 46-4 on page 1160 are estimated values of the power con- sumption with operating conditions as follows: ?v ddiom0 = 1.8v ?v ddiop0 and 1 = 3.3v ?v ddplla = 1.0v ?v ddcore = 1.0v ?v ddbu = 3.3v ?t a = 25 c ? there is no consumption on the i/os of the device figure 46-1. measures schematics i sc static current on v vddcore = 1.0v, mck = 0 hz, excluding por t a = 25c 30 ma all inputs driven tms, tdi, tck, nrst = 1 t a = 85c 120 on v vddbu = 3.3v, logic cells consumption, excluding por t a = 25c 9 a all inputs driven wkup = 0 t a = 85c 25 table 46-2. dc characteristics (continued) vddcore vddbu amp2 amp1
1160 6438fCatarmC21-jun-10 at91sam9g45 these figures represent the power consumption estimated on the power supplies. table 46-3. power consumption for different modes mode conditions consumption unit active arm core clock is 400 mhz. mck is 133 mhz. all peripheral clocks activated. onto amp2 130 ma idle idle state, waiting an interrupt. all peripheral clocks de-activated. onto amp2 55 ma ultra low power arm core clock is 500 hz. all peripheral clocks de-activated. onto amp2 30 ma backup device only v ddbu powered onto amp1 8 a table 46-4. power consumption by peripheral in active mode peripheral consumption unit pio controller 2.2 a/mhz usart 7.2 uhphs 53.2 udphs 21.7 tsadc 0.1 twi 1.3 spi 4.7 pwm 3.8 hsmci 25.6 ac97 5.3 ssc 6.6 timer counter channels 6.9 isi 4.8 lcd 20.4 dma 0.2 emac 34.8 trng 0.9
1161 6438fCatarmC21-jun-10 at91sam9g45 46.4 clock characteristics 46.4.1 processor clock characteristics 46.4.2 master clock characteristics the master clock is the maximum clock at which the system is able to run. it is given by the smallest value of the internal bus clock and ebi clock. note: 1. for ddr2 usage, there are no limitations to ldddr, sdram and mobile sdram. 46.5 main oscillator characteristics note: 1. the c crystal value is specified by the crystal manufacturer. in our case, c crystal must be between 15 pf and 20 pf. all par- asitic capacitance, package and board, must be calculated in order to reach 15 pf (minimum targeted load for the oscillator) by taking into account the internal load c int . so, to target the minimum oscillato r load of 15 pf, external capaci- tance must be: 15 pf - 4 pf = 11 pf whic h means that 22 pf is the target value (22 pf from xin to gnd and 22 pf from xout to gnd) if 20 pf load is target ed, the sum of pad, package, board and external capacitances must be 20 pf - 4 pf = 16 pf which means 32 pf (32 pf from xin to gnd and 32 pf from xout to gnd). table 46-5. processor clock waveform parameters symbol parameter conditions min max units 1/(t cppck ) processor clock frequency vddcore = 0.9v t = 85c 125 (1) 400 mhz table 46-6. master clock waveform parameters symbol parameter conditions min max units 1/(t cpmck ) master clock frequency vddcore = 0.9v t = 85c 125 (1) 133 mhz table 46-7. main oscillator characteristics symbol parameter conditions min typ max unit 1/(t cpmain ) crystal oscillator frequency 8 12 16 mhz c crystal (1) crystal load capacitance 15 20 pf c int (1) internal load capacitance 4 pf c lext external load capacitance c crystal = 15 pf (1) 22 pf c crystal = 20 pf (1) 32 pf duty cycle 40 50 60 % t st startup time 2ms i ddst standby current consumption standby mode 1 a p on drive level 150 w i dd on current dissipation @ 8 mhz 0.35 0.55 ma @ 16 mhz 0.7 1.1 ma
1162 6438fCatarmC21-jun-10 at91sam9g45 46.5.1 crystal oscillator characteristics the following characteristics are applicabl e to the operating temperature range: t a = -40c to 85c and worst case of power supply, unless otherwise specified. 46.5.2 xin clock characteristics note: 1. these characteristics apply only when the main oscillator is in bypass mode (i.e. when moscen = 0 and oscbypass = 1) in the ckgr_mor register. see pmc clock generator main oscillator register in the pmc section. xin xout gndpll c lext c lext c cry s tal at91 s am9g45 table 46-8. crystal characteristics symbol parameter conditions min typ max unit esr equivalent series resistor rs 80 c m motional capacitance 9ff c s shunt capacitance 7pf table 46-9. xin clock electrical characteristics symbol parameter conditions min max units 1/(t cpxin ) xin clock frequency 50 mhz t cpxin xin clock period 20 ns t chxin xin clock high half-period 0.4 x t cpxin 0.6 x t cpxin ns t clxin xin clock low half-period 0.4 x t cpxin 0.6 x t cpxin ns c in xin input capacitance (1) 25 pf r in xin pulldown resistor (1) 500 k v in xin voltage (1) vddosc vddosc v
1163 6438fCatarmC21-jun-10 at91sam9g45 46.6 32 khz oscillator characteristics notes: 1. r s is the equivalent series resistance. 2. c lext32 is determined by taking into account inte rnal, parasitic and package load capacitance. 46.6.1 32 khz crystal characteristics table 46-10. 32 khz oscillator characteristics symbol parameter conditions min typ max unit 1/(t cp32khz ) crystal oscillator frequency 32 768 khz c crystal32 load capacitance crystal @ 32.768 khz 6 12.5 pf c lext32 (2) external load capacitance c crystal32 = 6 pf 6 pf c crystal32 = 12.5 pf 19 pf duty cycle 40 60 % t st startup time r s = 50 k (1) c crystal32 = 6 pf 400 ms c crystal32 = 12.5 pf 900 ms r s = 100 k (1) c crystal32 = 6 pf 600 ms c crystal32 = 12.5 pf 1200 ms table 46-11. 32 khz crystal characteristics symbol parameter conditions min typ max unit esr equivalent series resistor rs crystal @ 32.768 khz 50 100 k c m motional capacitance crystal @ 32.768 khz 3 ff c s shunt capacitance crystal @ 32.768 khz 2 pf xin 3 2 xout 3 2 gndbu c lext 3 2 c lext 3 2 c cry s tal 3 2 at91 s am9g45
1164 6438fCatarmC21-jun-10 at91sam9g45 46.6.2 xin32 clock characteristics note: 1. these characteristics apply only when the 32.768khz osci llator is in bypass mode (i.e. when rcen = 0, osc32en = 0, oscsel = 1 and osc32byp = 1) in the sckcr regi ster. see slow clock select ion in the pmc section. 46.7 32 khz rc oscillator characteristics table 46-12. xin32 clock electrical characteristics symbol parameter conditions min max units 1/(t cpxin32 ) xin32 clock frequency 44 khz t cpxin32 xin32 clock period 22 s t chxin32 xin32 clock high half-period 11 s t clxin32 xin32 clock low half-period 11 s t clch32 xin32 clock rise time 400 ns t clcl32 xin32 clock fall time 400 ns c in32 xin32 input capacitance (1) 6pf r in32 xin32 pulldown resistor (1) 4m v in32 xin32 voltage (1) vddbu vddbu v v inil32 xin32 input low level voltage (1) -0.3 0.3 x v vddbu v v inih32 xin32 input high level voltage (1) 0.7 x v vddbu v vddbu + 0.3 v table 46-13. rc oscillator characteristics symbol parameter conditions min typ max unit 1/(t cprcz ) crystal oscillator frequency 22 42 khz duty cycle 45 55 % t st startup time 75 s
1165 6438fCatarmC21-jun-10 at91sam9g45 46.8 pll characteristics the following configuration of icplla and outa must be done for each plla frequency range. 46.8.1 utmi pll characteristics table 46-14. plla characteristics symbol parameter conditions min typ max unit f out output frequency refer to following table 400 800 mhz f in input frequency 2 32 mhz i pll current consumption active mode 3.6 4.5 ma standby mode 1 a t startup time 50 s table 46-15. plla frequency regarding icplla and outa pll frequency range (mhz) icplla outa 745 - 800 0 0 0 695 - 750 0 0 1 645 - 700 0 1 0 595 - 650 0 1 1 545 - 600 1 0 0 495 - 550 1 0 1 445 - 500 1 1 0 400 - 450 1 1 1 table 46-16. phase lock loop characteristics symbol parameter conditions min typ max unit f in input frequency 4 12 32 mhz f out output frequency 450 480 600 mhz i pll current consumption active mode 5 8 ma standby mode 1.5 a t startup time 50 s
1166 6438fCatarmC21-jun-10 at91sam9g45 46.9 i/os criteria used to define the maximum frequency of the i/os: ? output duty cycle (40%-60%) ? minimum output swing: 100 mv to vddio - 100 mv ? addition of rising and falling time inferior to 75% of the period notes: 1. v vddiop from 3.0v to 3.6v 2. v vddiop from 1.65v to 1.95v 46.10 usb hs characteristics 46.10.1 electrical characteristics 46.10.2 static power consumption note: 1. if cable is connected add 200 a (typical) due to pull-up/pull-down current consumption. table 46-17. i/o characteristics symbol parameter conditions min max units freqmax vddiop powered pins frequency 3.3v domain (1) max. external load = 20 pf max. external load = 40 pf 66 34 mhz 1.8v domain (2) max. external load = 20 pf max. external load = 40 pf 35 18 mhz table 46-18. electrical parameters symbol parameter conditions min typ max unit r pui bus pull-up resistor on upstream port (idle bus) in ls or fs mode 1.5 kohms r pua bus pull-up resistor on upstream port (upstream port receiving) in ls or fs mode 15 kohms setting time t bias bias settling time 20 s t osc oscillator settling time with crystal 12mhz 2 ms t settling settling time f in = 12 mhz 0.3 0.5 ms table 46-19. static power consumption symbol parameter conditions min typ max unit i bias bias current consumption on vbg 1a i vddutmii hs transceiver and i/o current consumption 8a ls / fs transceiver and i/o current consumption no connection(1) 3 a i vddutmic core, pll, and oscillator current consumption 2 a
1167 6438fCatarmC21-jun-10 at91sam9g45 46.10.3 dynamic power consumption note: 1. including 1ma due to pull -up/pull-down current consumption. table 46-20. dynamic power consumption symbol parameter conditions min typ max unit i bias bias current consumption on vbg 0.7 0.8 ma i vddutmii hs transceiver current consumption hs transmission 47 60 ma hs transceiver current consumption hs reception 18 27 ma ls / fs transceiver current consumption fs transmission 0m cable(1) 4 6 ma ls / fs transceiver current consumption fs transmission 5m cable(1) 26 30 ma ls / fs transceiver current consumption fs reception(1) 3 4.5 ma i vddutmic pll, core and oscillator current consumption 5.5 9 ma
1168 6438fCatarmC21-jun-10 at91sam9g45 46.11 touch screen adc (tsadc) note: 1. the track and hold acquisition time is given by: the adc internal clock is divided by 2 in order to generate a clock with a duty cycle of 75%. so the maximum conversion time is give by: the full speed is obtained for an input source impedance of < 50 ohms maximum, or tth = 500 ns. in order to make the tsadc work properly, the shtim field in tsadcc mode register is to be calculated according to this track and hold acquisition time, also called sampled and hold time. table 46-21. channel conversion time and adc clock parameter conditions min typ max units adc clock frequency 10-bit resolution mode 13.2 mhz startup time return from idle mode 40 s track and hold acquisition time (tth) adc clock = 13.2 mhz (1) 0.5 s conversion time (tct) adc clock = 13.2 mhz (1) 1.75 s throughput rate adc clock = 13.2 mhz (1) 440 ksps table 46-22. external voltage reference input parameter conditions min typ max units advref input voltage range 2.4 vddana v advref average current 600 a current consumption on vddana 300 a tth (ns) 500 0.12 z in () () + = tct s () 23 fclk ---------- - mhz () = table 46-23. analog inputs parameter min typ max units input voltage range 0 advref v input leakage current 1a input capacitance 710pf input impedance 50 ohms table 46-24. transfer characteristics parameter min typ max units resolution 10 bit integral non-linearity 2 lsb differential non-linearity -0.9 +0.9 lsb offset error -1.5 0.5 10 mv gain error 2 lsb
1169 6438fCatarmC21-jun-10 at91sam9g45 46.12 core power supply por characteristics 46.12.1 power sequence requirements the at91sam9g45 board design must comply with the power-up guidelines below to guaran- tee reliable operation of the device. any deviat ion from these sequences may prevent the device from booting. 46.12.2 power-up sequence figure 46-2. vddcore and vddio constraints at startup vddcore and vddbu are controlled by internal por (power-on-reset) to guarantee that these power sources reach their target values prior to the release of por. ? vddiop must be v ih (refer to dc characteristics, table 46-2 , for more details) within (tres + t1) after vddcore has reached v th+ . ? vddiom must reach v oh (refer to dc characteristics, table 46-2 , for more details) within (tres +t1 +t2) after vddcore has reached v th+ Ct res is a por characteristic Ct1 = 3 x t slck C t2 = 16 x t slck table 46-25. power-on-reset characteristics symbol parameter conditions min typ max units v th+ threshold voltage rising minimum slope of +2.0v/30ms 0.5 0.7 0.89 v v th- threshold voltage falling 0.4 0.6 0.85 v t res reset time 30 70 130 s vdd (v) core su pply por o u tp u t vddiotyp vi h vt h + t s lck <--- tre s ---> vddio > vih vddcore vddio < t1 > vddcoretyp voh vddio > voh <------------ t2----------->
1170 6438fCatarmC21-jun-10 at91sam9g45 the t slck min (22 s) is obtained for the maximum frequency of the internal rc oscillator (44khz). Ct res = 30 s C t1 = 66 s C t2 = 352 s 46.13 smc timings 46.13.1 timing conditions smc timings are given for max corners. timings are given assuming a capacitance load on data, control and address pads: in the following tables, t cpmck is mck period. 46.13.2 timing extraction 46.13.2.1 zero hold mode restrictions 46.13.2.2 read timings table 46-26. capacitance load corner supply max min 3.3v 50pf 5 pf 1.8v 30 pf 5 pf table 46-27. zero hold mode use maximum system clock frequency (mck) symbol parameter min units vddiom supply 1.8v 3.3v zero hold mode use fmax mck frequency 66 66 mhz table 46-28. smc read signals - nrd controlled (read_mode= 1) symbol parameter min units vddiom supply 1.8v 3.3v no hold settings (nrd hold = 0) smc 1 data setup before nrd high 12.0 11.2 ns smc 2 data hold after nrd high 0 0 ns hold settings (nrd hold 0) smc 3 data setup before nrd high 8.7 8.2 ns
1171 6438fCatarmC21-jun-10 at91sam9g45 46.13.2.3 write timings smc 4 data hold after nrd high 0 0 ns hold or no hold settings (nrd hold 0, nrd hold =0) smc 5 nbs0/a0, nbs1, nbs2/a1, nbs3, a2 - a25 valid before nrd high (nrd setup + nrd pulse)* t cpmck - 15.4 (nrd setup + nrd pulse)* t cpmck - 15.5 ns smc 6 ncs low before nrd high (nrd setup + nrd pulse - ncs rd setup) * t cpmck -14.7 (nrd setup + nrd pulse - ncs rd setup) * t cpmck - 14.7 ns smc 7 nrd pulse width nrd pulse * t cpmck - 0.5 nrd pulse * t cpmck - 0.2 ns table 46-28. smc read signals - nrd controlled (read_mode= 1) (continued) table 46-29. smc read signals - ncs controlled (read_mode= 0) symbol parameter min units vddiom supply 1.8v 3.3v no hold settings (ncs rd hold = 0) smc 8 data setup before ncs high 15.0 14.1 ns smc 9 data hold after ncs high 0 0 ns hold settings (ncs rd hold 0) smc 10 data setup before ncs high 11.4 10.9 ns smc 11 data hold after ncs high 0 0 ns hold or no hold settings (ncs rd hold 0, ncs rd hold = 0) smc 12 nbs0/a0, nbs1, nbs2 /a1, nbs3, a2 - a25 valid before ncs high (ncs rd setup + ncs rd pulse)* t cpmck - 3.7 (ncs rd setup + ncs rd pulse)* t cpmck - 4.4 ns smc 13 nrd low before ncs high (ncs rd setup + ncs rd pulse - nrd setup)* t cpmck - 0.8 (ncs rd setup + ncs rd pulse - nrd setup)* t cpmck - 1.1 ns smc 14 ncs pulse width ncs rd pulse length * t cpmck - 0.5 ncs rd pulse length * t cpmck - 0.2 ns table 46-30. smc write signals - nwe controlled (write_mode = 1) symbol parameter min units 1.8v supply 3.3v supply hold or no hold settings (nwe hold 0, nwe hold = 0) smc 15 data out valid before nwe high nwe pulse * t cpmck - 2.9 nwe pulse * t cpmck - 3.6 ns smc 16 nwe pulse width nwe pulse * t cpmck - 0.7 nwe pulse * t cpmck - 0.3 ns smc 17 nbs0/a0 nbs1, nbs2/a1, nbs3, a2 - a25 valid before nwe low nwe setup * t cpmck - 3.3 nwe setup * t cpmck - 4.1 ns smc 18 ncs low before nwe high (nwe setup - ncs rd setup + nwe pulse) * t cpmck - 3.1 (nwe setup - ncs rd setup + nwe pulse) * t cpmck - 3.4 ns hold settings (nwe hold 0)
1172 6438fCatarmC21-jun-10 at91sam9g45 notes: 1. hold length = total cycle duration - setup duration - pulse duration. hold length is for ncs wr hold length or nwe hold length. ) smc 19 nwe high to data out, nbs0/a0 nbs1, nbs2/a1, nbs3, a2 - a25 change nwe hold * t cpmck - 4.0 nwe hold * t cpmck - 4.6 ns smc 20 nwe high to ncs inactive (1) (nwe hold - ncs wr hold)* t cpmck - 3.2 (nwe hold - ncs wr hold)* t cpmck - 4.0 ns no hold settings (nwe hold = 0) smc 21 nwe high to data out, nbs0/a0 nbs1, nbs2/a1, nbs3, a2 - a25, ncs change (1) 1.6 1.4 ns table 46-30. smc write signals - nwe controlled (write_mode = 1) (continued) symbol parameter min units 1.8v supply 3.3v supply table 46-31. smc write ncs controlled (write_mode = 0) symbol parameter min units 1.8v supply 3.3v supply smc 22 data out valid before ncs high ncs wr pulse * t cpmck - 2.8 ncs wr pulse * t cpmck - 3.5 ns smc 23 ncs pulse width ncs wr pulse * t cpmck - 0.5 ncs wr pulse * t cpmck - 0.2 ns smc 24 nbs0/a0 nbs1, nbs2/a1, nbs3, a2 - a25 valid before ncs low ncs wr setup * t cpmck - 3.3 ncs wr setup * t cpmck - 4.1 ns smc 25 nwe low before ncs high (ncs wr setup - nwe setup + ncs pulse)* t cpmck - 2.4 (ncs wr setup - nwe setup + ncs pulse)* t cpmck - 2.7 ns smc 26 ncs high to data out, nbs0/a0, nbs1, nbs2/a1, nbs3, a2 - a25, change ncs wr hold * t cpmck - 4.1 ncs wr hold * t cpmck - 4.6 ns smc 27 ncs high to nwe inactive (ncs wr hold - nwe hold)* t cpmck - 2.0 (ncs wr hold - nwe hold)* t cpmck - 2.8 ns
1173 6438fCatarmC21-jun-10 at91sam9g45 figure 46-3. smc timings - ncs controlled read and write figure 46-4. smc timings - nrd controlled r ead and nwe controlled write nrd ncs d0 - d15 nwe ncs controlled read with no hold ncs controlled read with hold ncs controlled write smc22 smc26 smc10 smc11 smc12 smc9 smc8 smc14 smc14 smc23 smc27 smc26 a0/a1/nbs[3:0]/a2-a25 smc24 smc25 smc12 smc13 smc13 nrd ncs d0 - d31 nwe a0/a1/nbs[3:0]/a2-a25 nrd controlled read with no hold nwe controlled write with no hold nrd controlled read with hold nwe controlled write with hold smc1 smc2 smc15 smc21 smc3 smc4 smc15 smc19 smc20 smc7 smc21 smc16 smc7 smc16 smc19 smc21 smc17 smc18 smc5 smc5 smc6 smc6 smc17 smc18
1174 6438fCatarmC21-jun-10 at91sam9g45 46.14 ddrsdrc timings the ddrsdrc controller satisfies the timings of standard ddr2, lp-ddr, sdr and lp-sdr modules. ddr2, lp-ddr and sdr timings are specified by the jedec standard. supported speed grade limitations: ? ddr2-400 limited at 133mhz clock frequency (1.8v, 30pf on data/control, 10pf on ck/ck#) ? lp-ddr (1.8v, 30pf on data/control, 10pf on ck) tcyc = 5.0 ns, fmax = 125 mhz tcyc = 6.0 ns, fmax = 110 mhz tcyc = 7.5 ns, fmax = 95 mhz ? sdr-100 (3.3v, 50pf on data/control, 10pf on ck) ? sdr-133 (3.3v, 50pf on data/control, 10pf on ck) ? lp-sdr-133 (1.8v, 30pf on data/control, 10pf on ck) 46.15 peripheral timings 46.15.1 spi 46.15.1.1 maximum spi frequency the following formulas give maximum spi frequency in master read and write modes and in slave read and write modes. master write mode the spi is only sending data to a slave device such as an lcd, for example. the limit is given by spi 2 (or spi 5 ) timing. since it gives a maximum frequency above the maximum pad speed (see section 46.9 i/os ), the max spi frequency is the one from the pad. master read mode t valid is the slave time response to output dat a after deleting an spck edge. for atmel spi dataflash (at45db642d), t valid (ort v ) is 12 ns max. in the formula above, f spck max = 38.5 mhz @ vddio = 3.3v. slave read mode in slave mode, spck is the input clock fo r the spi. the max spck frequency is given by setup and hold timings spi 7 /spi 8 (or spi 10 /spi 11 ). since this gives a frequency well above the pad limit, the limit in slave read mode is given by spck pad. slave write mode for 3.3v i/o domain and spi6, f spck max = 33 mhz. t setup is the setup time from the master before sampling data. f spck max 1 spi 0 orspi 3 () t valid + -------------------------------------------------------- = f spck max 1 spi 6 orspi 9 () t setup + -------------------------------------------------------- - =
1175 6438fCatarmC21-jun-10 at91sam9g45 46.15.1.2 timing conditions timings are given assuming a capacitance load on miso, spck and mosi : 46.15.1.3 timing extraction figure 46-5. spi master mode 1 and 2 figure 46-6. spi master mode 0 and 3 table 46-32. capacitance load for miso, spck and mosi (product dependent) corner supply max min 3.3v 40 pf 5 pf 1.8v 20 pf 5 pf spck miso mosi spi 2 spi 0 spi 1 spck miso mosi spi 5 spi 3 spi 4
1176 6438fCatarmC21-jun-10 at91sam9g45 figure 46-7. spi slave mode 0 and 3) figure 46-8. spi slave mode 1 and 2 spck miso mosi spi 6 spi 7 spi 8 npcs0 spi 12 spi 13 spck miso mosi spi 9 spi 10 spi 11 npcs0 spi 12 spi 13
1177 6438fCatarmC21-jun-10 at91sam9g45 figure 46-9. spi slave mode - npcs timings spck (cpol = 0) miso spi 14 spi 16 spi 12 spi 15 spi 13 spck (cpol = 1) spi 6 spi 9 table 46-33. spi timings with 3.3v peripheral supply symbol parameter cond min max units master mode spi spck spi clock 66 mhz spi 0 miso setup time before spck rises 14.6 ns spi 1 miso hold time after spck rises 0 ns spi 2 spck rising to mosi 0 0.2 ns spi 3 miso setup time before spck falls 14.3 ns spi 4 miso hold time after spck falls 0 ns spi 5 spck falling to mosi 0 0.6 ns slave mode spi 6 spck falling to miso 4.6 15.1 ns spi 7 mosi setup time before spck rises 0.7 ns spi 8 mosi hold time af ter spck rises 1.9 ns spi 9 spck rising to miso 4.6 15.2 ns spi 10 mosi setup time before spck falls 0.9 ns spi 11 mosi hold time after spck falls 1.4 ns spi 12 npcs0 setup to spck rising 17.3 ns spi 13 npcs0 hold after spck falling 15.1 ns spi 14 npcs0 setup to spck falling 18 ns spi 15 npcs0 hold after spck rising 15.0 ns spi 16 npcs0 falling to miso valid 4.4 14.5 ns
1178 6438fCatarmC21-jun-10 at91sam9g45 figure 46-10. min and max access time for spi output signal 46.15.2 ssc 46.15.2.1 timing conditions timings are given assuming a capacitance load on table 46-35 . table 46-34. spi timings with 1.8v peripheral supply symbol parameter cond min max units master mode spi spck spi clock 66 mhz spi 0 miso setup time before spck rises 18.0 ns spi 1 miso hold time after spck rises 0 ns spi 2 spck rising to mosi 0 0.2 ns spi 3 miso setup time before spck falls 17.6 ns spi 4 miso hold time after spck falls 0 ns spi 5 spck falling to mosi 0 0.7 ns slave mode spi 6 spck falling to miso 6.0 18.9 ns spi 7 mosi setup time before spck rises 0.7 ns spi 8 mosi hold time af ter spck rises 1.7 ns spi 9 spck rising to miso 5.5 18.7 ns spi 10 mosi setup time before spck falls 0.5 ns spi 11 mosi hold time after spck falls 1.4 ns spi 12 npcs0 setup to spck rising 17.4 ns spi 13 npcs0 hold after spck falling 15.5 ns spi 14 npcs0 setup to spck falling 17.8 ns spi 15 npcs0 hold after spck rising 15.3 ns spi 16 npcs0 falling to miso valid 5.4 17.7 ns spck miso mosi spi 2max spi 0 spi 1 spi 2min
1179 6438fCatarmC21-jun-10 at91sam9g45 46.15.2.2 timing extraction figure 46-11. ssc transmitter, tk and tf in output figure 46-12. ssc transmitter, tk in input and tf in output table 46-35. capacitance load corner supply max min 3.3v 30pf 0 pf 1.8v 20pf 0 pf tk (cki =1) tf/td ssc 0 tk (cki =0) tk (cki =1) tf/td ssc 1 tk (cki =0)
1180 6438fCatarmC21-jun-10 at91sam9g45 figure 46-13. ssc transmitter, tk in output and tf in input figure 46-14. ssc receiver rk and rf in input figure 46-15. ssc receiver, rk in input and rf in output tk (cki=1) tf ssc 2 ssc 3 tk (cki=0) td ssc 4 rk (cki=1) rf/rd ssc 8 ssc 9 rk (cki=0) rk (cki=0) rd ssc 8 ssc 9 rk (cki=1) rf ssc 10
1181 6438fCatarmC21-jun-10 at91sam9g45 figure 46-16. ssc receiver, rk and rf in output figure 46-17. ssc receiver, rk in ou tput and rf in input rk (cki=0) rd ssc 11 ssc 12 rk (cki=1) rf ssc 13 rk (cki=1) rf/rd ssc 11 ssc 12 rk (cki=0) table 46-36. ssc timings with 3.3v peripheral supply symbol parameter cond min max units transmitter ssc 0 tk edge to tf/td (tk output, tf output) 0 (2) 4.0 (2) ns ssc 1 tk edge to tf/td (tk input, tf output) 3.7 (2) 13.6 (2) ns ssc 2 tf setup time before tk edge (tk output) 14.3 - t cpmck ns ssc 3 tf hold time after tk edge (tk output) t cpmck - 3.9 ns ssc 4 (1) tk edge to tf/td (tk output, tf input) -2.6 (+2*t cpmck ) (1)(2) 4.0 (+2*t cpmck ) (1)(2) ns ssc 5 tf setup time before tk edge (tk input) 0 ns ssc 6 tf hold time after tk edge (tk input) t cpmck ns ssc 7 (1) tk edge to tf/td (tk input, tf input) 3.8 (+3*t cpmck ) (1)(2) 13.6 (+3*t cpmck ) (1)(2) ns receiver ssc 8 rf/rd setup time before rk edge (rk input) 1.9 ns ssc 9 rf/rd hold time after rk edge (rk input) t cpmck ns ssc 10 rk edge to rf (rk input) 4.3 (2) 16.9 (2) ns
1182 6438fCatarmC21-jun-10 at91sam9g45 notes: 1. timings ssc4 and ssc7 depend on the start condition. when sttdly = 0 (receive start delay) and start = 4, or 5 or 7 (receive start selection), two periods of the mck must be added to timings. 2. for output signals (tf, td, rf), min and max access times are defined. the min access time is the time between the tk (or rk) edge and the signal change. the max access time is t he time between the tk edge and the signal stabilization. figure 46-18 illustrates min and max accesses for ssc0. the sa me applies to ssc1, ssc4, and ssc7, ssc10 and ssc13. notes: 1. timings ssc4 and ssc7 depend on the start condition. when sttdly = 0 (receive start delay) and start = 4, or 5 or 7 (receive start selection), two periods of the mck must be added to timings. 2. for output signals (tf, td, rf), min and max access times are defined. the min access time is the time between the tk (or rk) edge and the signal change. the max access time is t he time between the tk edge and the signal stabilization. figure 46-18 illustrates min and max accesses for ssc0. the sa me applies to ssc1, ssc4, and ssc7, ssc10 and ssc13. ssc 11 rf/rd setup time before rk edge (rk output) 14.2 - t cpmck ns ssc 12 rf/rd hold time after rk edge (rk output) t cpmck - 3.9 ns ssc 13 rk edge to rf (rk output) 0 (2) 5.2 (2) ns table 46-36. ssc timings with 3.3v peripheral supply (continued) symbol parameter cond min max units table 46-37. ssc timings with 1.8v peripheral supply symbol parameter cond min max unit s transmitter ssc 0 tk edge to tf/td (tk output, tf output) 0 (2) 4.2 (2) ns ssc 1 tk edge to tf/td (tk input, tf output) 4.8 (2) 18.4 (2) ns ssc 2 tf setup time before tk edge (tk output) 18.4 - t cpmck ns ssc 3 tf hold time after tk edge (tk output) t cpmck - 5.1 ns ssc 4 (1) tk edge to tf/td (tk out put, tf input) -2.8 (+2*t cpmck ) (1)(2) 4.2 (+2*t cpmck ) (1)(2) ns ssc 5 tf setup time before tk edge (tk input) 0.6 ns ssc 6 tf hold time after tk edge (tk input) t cpmck ns ssc 7 (1) tk edge to tf/td (tk input, tf input) 5.0 (+3*t cpmck ) (1)(2) 18.3 (+3*t cpmck ) (1)(2) ns receiver ssc 8 rf/rd setup time before rk edge (rk input) 2.4 ns ssc 9 rf/rd hold time after rk edge (rk input) t cpmck ns ssc 10 rk edge to rf (rk input) 5.4 (2) 21.5 (2) ns ssc 11 rf/rd setup time before rk edge (rk output) 18.6 - t cpmck ns ssc 12 rf/rd hold time after rk edge (rk output) t cpmck - 5.1 ns ssc 13 rk edge to rf (rk output) 0 (2) 5.3 (2) ns
1183 6438fCatarmC21-jun-10 at91sam9g45 figure 46-18. min and max access time of output signals 46.15.3 isi 46.15.3.1 timing conditions timings are given assuming capacitance loads on table 46-38 . 46.15.3.2 timing extraction figure 46-19. isi timing diagram tk (cki =0) tf/td ssc 0min tk (cki =1) ssc 0max table 46-38. capacitance load corner supply max min 3.3v 30pf 0 pf 1.8v 20pf 0 pf table 46-39. isi timings with 3.3v peripheral supply symbol parameter min max units isi 1 data/vsync/hsync setup time 1.1 ns isi 2 data/vsync/hsync hold time 2.0 ns isi 3 pixclk frequency 80 mhz pixclk data[7:0] vsync hsync valid data valid data valid data 1 2 3
1184 6438fCatarmC21-jun-10 at91sam9g45 46.15.4 hsmci the high speed multimedia card interface (hsmci) supports the multimedia card (mmc) specification v4.3, the sd memo ry card specification v2.0, th e sdio v2.0 specification and ce-ata v1.1. 46.15.5 emac 46.15.5.1 timing conditions timings are given assuming a capacitance load on data and clock: 46.15.5.2 timing constraints the ethernet controller must satisfy the timings of max corner standards given in table 46-42 and table 46-43 . notes: 1. for emac output signals, min and max access time are defined. the min access time is the time between the edmc falling edge and the signal change. the max access time is the time between the edmc falling edge and the signal stabilization. figure 46-20 illustrates min and max accesses for emac3. table 46-40. isi timings with 1.8v peripheral supply symbol parameter min max units isi 1 data/vsync/hsync setup time 1.1 ns isi 2 data/vsync/hsync hold time 2.2 ns isi 3 pixclk frequency 80 mhz table 46-41. capacitance load on data, clock pads corner supply max min 3.3v 20pf 0pf 1.8v 20pf 0pf table 46-42. emac signals relative to emdc symbol parameter min (ns) max (ns) emac 1 setup for emdio from emdc rising 13.5 emac 2 hold for emdio from emdc rising 10 emac 3 emdio toggling from emdc falling 0 (1) 2 (1)
1185 6438fCatarmC21-jun-10 at91sam9g45 figure 46-20. min and max access time of emac output signals 46.15.5.3 mii mode emdc emdio emac 3 max emac 1 emac 2 emac 4 emac 5 emac 3 min table 46-43. emac mii specific signals symbol parameter min (ns) max (ns) emac 4 setup for ecol from etxck rising 10 emac 5 hold for ecol from etxck rising 10 emac 6 setup for ecrs from etxck rising 10 emac 7 hold for ecrs from etxck rising 10 emac 8 etxer toggling from etxck rising 3 25 emac 9 etxen toggling from etxck rising 4.7 25 emac 10 etx toggling from etxck rising 3 25 emac 11 setup for erx from erxck 10 emac 12 hold for erx from erxck 10 emac 13 setup for erxer from erxck 10 emac 14 hold for erxer from erxck 10 emac 15 setup for erxdv from erxck 10 emac 16 hold for erxdv from erxck 10
1186 6438fCatarmC21-jun-10 at91sam9g45 figure 46-21. emac mii mode notes: 1. see note (2) of table 46-42 . emdc emdio ecol ecrs etxck etxer etxen etx[3:0] erxck erx[3:0] erxer erxdv emac 3 emac 1 emac 2 emac 4 emac 5 emac 6 emac 7 emac 8 emac 9 emac 10 emac 11 emac 12 emac 13 emac 14 emac 15 emac 16 table 46-44. rmii mode symbol parameter min (ns) max (ns) emac 21 etxen toggling from erefck rising 2 17.8 emac 22 etx toggling from erefck rising 2 16 emac 23 setup for erx from erefck rising 4 emac 24 hold for erx from erefck rising 2 emac 25 setup for erxer from erefck rising 4 emac 26 hold for erxer from erefck rising 2 emac 27 setup for ecrsdv from erefck rising 4
1187 6438fCatarmC21-jun-10 at91sam9g45 figure 46-22. emac rmii timings 46.15.6 uart in spi mode 46.15.6.1 timing conditions timings are given assuming a capacitance load on miso, spck and mosi : erefck etxen etx[1:0] erx[1:0] erxer ecrsdv emac 21 emac 22 emac 23 emac 24 emac 25 emac 26 emac 27 emac 28 table 46-45. capacitance load for miso, spck and mosi (product dependent) corner supply max min 3.3v 40pf 0 pf 1.8v 20 pf 0 pf
1188 6438fCatarmC21-jun-10 at91sam9g45 46.15.6.2 timing extraction figure 46-23. uart spi master mode figure 46-24. uart spi slave mode npc s x s pi 0 m s b l s b s pi 1 cpol=1 cpol=0 mi s o mo s i s pck=0 s pi 5 s pi 2 s pi 3 s pi 4 s pi 4 spck miso mosi spi 6 spi 7 spi 8 npcs0 spi 12 spi 13
1189 6438fCatarmC21-jun-10 at91sam9g45 figure 46-25. spi slave mode - npcs timings notes: 1. for output signals, min and max access time must be extracted. the min access time is the time between the spck rising or falling edge and the signal change. the max access time is the time between the spck rising or falling edge and the signal stabilization. figure 46-9 illustrates min and max accesses for spi2. the same applies to spi5, spi6, spi9. table 46-46. uart spi timings with 3.3v peripheral supply symbol parameter cond min max units master mode spi 0 spck period ns spi 1 input data setup time 17.2 ns spi 2 input data hold time 0 ns spi 3 chip select active to serial clock 3.5 ns spi 4 output data setup time 0.2 ns spi 5 serial clock to chip select inactive -0.3 ns slave mode spi 6 spck falling to miso 13.8 (1) 16.9 (1) ns spi 7 mosi setup time before spck rises 7.5 ns spi 8 mosi hold time after spck rises 2.9 ns spi 9 spck rising to miso 4.7 (1) 17.1 (1) ns spi 10 mosi setup time before spck falls 0.4 ns spi 11 mosi hold time after spck falls 0 ns spi 12 npcs0 setup to spck rising 10.3 ns spi 13 npcs0 hold after spck falling 2.0 ns spi 14 npcs0 setup to spck falling 10.7 ns spi 15 npcs0 hold after spck rising 2.0 ns spi 16 npcs0 falling to miso valid 16.0 ns spck (cpol = 0) miso spi 14 spi 16 spi 12 spi 15 spi 13 spck (cpol = 1) spi 6 spi 9
1190 6438fCatarmC21-jun-10 at91sam9g45 table 46-47. uart spi timings with 1.8v peripheral supply symbol parameter cond min max units master mode spi 0 spck period ns spi 1 input data setup time 20.6 ns spi 2 input data hold time 0 ns spi 3 chip select active to serial clock 6.0 ns spi 4 output data setup time 0.2 ns spi 5 serial clock to chip select inactive 0 ns slave mode spi 6 spck falling to miso 4.4 20.7 ns spi 7 mosi setup time before spck rises 7.6 ns spi 8 mosi hold time after spck rises 3.1 ns spi 9 spck rising to miso 5.6 20.6 ns spi 10 mosi setup time before spck falls 0.8 ns spi 11 mosi hold time after spck falls 0 ns spi 12 npcs0 setup to spck rising 10.2 ns spi 13 npcs0 hold after spck falling 1.9 ns spi 14 npcs0 setup to spck falling 11.0 ns spi 15 npcs0 hold after spck rising 2.2 ns spi 16 npcs0 falling to miso valid 18.9 ns
1191 6438fCatarmC21-jun-10 at91sam9g45 47. at91sam9g45 mechani cal characteristics 47.1 package drawings figure 47-1. 324-ball tfbga package drawing
1192 6438fCatarmC21-jun-10 at91sam9g45 this package respects the recommendations of the nemi user group. 47.2 soldering profile table 47-5 gives the recommended soldering profile from j-std-020c. note: it is recommended to apply a soldering temperature higher than 250c a maximum of three reflow passes is allowed per component. table 47-1. soldering information ball land 0.4 mm +/- 0.05 soldering mask opening 0.275 mm +/- 0.03 table 47-2. device and 324-ball tfbga package maximum weight 400 mg table 47-3. 324-ball tfbga package characteristics moisture sensitivity level 3 table 47-4. package reference jedec drawing reference mo-210 jesd97 classification e1 table 47-5. soldering profile profile feature green package average ramp-up rate (217c to peak) 3 c/sec. max. preheat temperature 175c 25c 180 sec. max. temperature maintained above 217c 60 sec. to 150 sec. time within 5 c of actual peak temperature 20 sec. to 40 sec. peak temperature range 260 +0 c ramp-down rate 6 c/sec. max. time 25 c to peak temperature 8 min. max.
1193 6438fCatarmC21-jun-10 at91sam9g45 48. at91sam9g45 ordering information table 48-1. at91sam9g45 ordering information ordering code package package type temperature operating range at91sam9g45-cu tfbga324 green industrial -40c to 85c
1194 6438fCatarmC21-jun-10 at91sam9g45
1195 6438fCatarmC21-jun-10 at91sam9g45 49. at91sam9g45 errata 49.1 marking all devices are marked with the atmel logo and the ordering code. additional marking may be in one of the following formats: where ?yy: manufactory year ? ww: manufactory week ? v: revision ? xxxxxxxxx: lot number errata on engineering samples of the at91sam9g45 is available at http://www.atmel.com/dyn/resources/prod_documents/doc6485.pdf. yyww v xxxxxxxxx arm
1196 6438fCatarmC21-jun-10 at91sam9g45 49.2 errata 49.2.1 boot rom 49.2.1.1 boot rom: nand flash boot does not support ecc correction the boot rom allows booting from block 0 of a nand flash connected on cs3. however, the boot rom does not feature ecc correction on a nand flash. most of the nand flash vendors do not guarantee anymore that block 0 is error free. therefore we advise to locate the bootstrap program into another device supported by the boot rom (dataflash, serial flas h, sdcard or eeprom), and to im plement a nand flash access with ecc. problem/fix workaround none. 49.2.2 error corrected code controller (ecc) 49.2.2.1 ecc: computation with a 1 clock cycle long nrd/nwe pulse if the smc is programmed with nrd/nwe pulse le ngth equal to 1 clo ck cycle, hecc can't com- pute the parity. problem/fix workaround it is recommended to program smc with a value superior to 1. 49.2.2.2 uncomplete parity status when error in ecc parity when a single correctable error is detected in ecc value, the error is located in ecc parity reg- ister's field which contains a 1 in the 24 least significant bits except when the error is located in the 12th or the 24th bit. in this case, these bits are always stuck at 0. a single correctable error is detected but it is impossible to correct it. problem/fix workaround none. 49.2.2.3 unsupported ecc per 512 words 1 bit ecc per 512 words is not functional. problem/fix workaround perform the ecc comput ation by software. 49.2.2.4 unsupported hardware ecc on 16-bit nand flash hardware ecc on 16-bit nand flash is not supported. problem/fix workaround perform the ecc by software. 49.2.3 pulse width modulation controller (pwm) 49.2.3.1 pwm: zero period it is impossible to update a period e qual to 0 by using the pwm_cupd register. problem/fix workaround none
1197 6438fCatarmC21-jun-10 at91sam9g45 49.2.4 static memory controller (smc) 49.2.4.1 smc delay: access in this document, the access is read-write in the register mapping table (smc_delay1 to smc_delay8 rows), and in the smc delay i/o register. the current access is write-only. problem/fix workaround none 49.2.5 serial synchronous controller (ssc) 49.2.5.1 ssc: data sent without any frame synchro when ssc is configured wit h the following conditions: ? rf is in input, ? td is synchronized on a receive start (any condition: start field = 2 to 7) ? tf toggles at each start of data transfer ? transmit sttdly = 0 ? check td and tf after a receive start, the data is sent but there is not any toggle of the tf line problem/fix workaround transmit sttdly must be different from 0. 49.2.5.2 ssc: unexpected delay on td output when ssc is configured wit h the following conditions: ? tcmr.sttdly more than 0 ? rcmr.start = start on falling edge/sta rt on rising edge/start on any edge ? rfmr.fsos = none (input) ? tcmr.start = receive start unexpected delay of 2 or 3 system clock cycles is added to td output. problem/fix workaround none 49.2.6 touch screen (tsadcc) 49.2.6.1 tsadcc: pen detect accuracy is not good depending on lcd panels, the pen detect is no isy, leading to an unpredictable behavior. problem/fix workaround an additional resistor solves the problem. its value (between 100 kohm and 250 kohm) is to be tuned for the lcd panel.
1198 6438fCatarmC21-jun-10 at91sam9g45 49.2.7 usb high speed host port (uhphs) and device port (udphs) 49.2.7.1 usb does not start after power-up the usb may not start properly at first use after power-up. if the device boots out of the inte rnal rom, sam-ba will not be functional. problem/fix workaround 1. apply a hardware reset (nrst) after power-up. 2. activate the pllutmi twice, following the procedure below: C a- start the utmi pll an wait for the pll lock bit C b- disable the utmi pll and wait 10 seconds minimum C c- restart the utmipll and wait for the pll lock bit warning: when booting out of the internal rom, this workaround is not implemented and there- fore samba will not be functional. below is a possible implementation of the workaround: /* first enable the utmi pll */ at91c_base_pmc->ckgr_uckr |= (at91c_ckgr_uckr_pllcount & (0x3 << 20)) | at91c_ckgr_uckr_upllen; tmp =0; while (((at91c_base_pmc->p mc_sr & at91c_pmc_sr_locku) == 0) && (tmp++ < delay)); /* disable the pllutmi and wait 10s min*/ at91c_base_pmc->ckgr_uckr &= ~at91c_ckgr_uckr_upllen; tmp = 0; while(tmp++ < delay2); // delay2 must be defined to fit the 10s min;
1199 6438fCatarmC21-jun-10 at91sam9g45 /* re- enable the utmi pll and wait for the pll lock status*/ at91c_base_pmc->ckgr_uckr |= (at91c_ckgr_uckr_pllcount & (0x3 << 20)) | at91c_ckgr_uckr_upllen; tmp =0; while (((at91c_base_pmc->p mc_sr & at91c_pmc_sr_locku) == 0) && (tmp++ < delay));
1200 6438fCatarmC21-jun-10 at91sam9g45
1201 6438fCatarmC21-jun-10 at91sam9g45 revision history in the tables that follow, the most recent version appears first. doc. rev comments change request ref. 6438f bus matrix - ebi_drive and ddr_drive bitfields edited in ebi chip select assignment register - 12-layer matrix instead of 11-layer 6930 7171 ddrsdrc in section 22.7.6 ddrsdrc timing 2 parameter register , - trtp bitfield reset value (0 --> 2) changed. - 0 and 15 cycles changed into 0 and 7 in trtp: re ad to precharge. - txard (-->2), txards (-->6), and tr pa (-->0) reset values changed. in section 22.7.7 ddrsdrc low-power register , upd_mr bitfield added to the table at [21:20]. in section 22.4.4.1 self refresh mode , udp_en bitfield replaced by upd_mr. 7134 7146 electrical characteristics - figure below table 46-7, main oscillator characteristics edited. - section 46.14 ddrsdrc timings updated. - table 46-17 i/o characteristics and notes below edited. - ultra low power mode value changed in table 46-3, power consum ption for different modes . - section 46.15.1.1 m aximum spi frequency added. 7063 7134 -7193 6926 7195 7173 errata - boot rom errata added . - static memory controller (smc) errata added. - touch screen (tsadcc) errata added . - usb high speed host port (uhphs) and device port (udphs) errata added . - 3 error corrected code controller (ecc) errata added: uncomplete parity status when error in ecc parity , unsupported ecc per 512 words and unsupported hardware ecc on 16-bit nand flash 7148 6977 7165 7194 7192 external memories - dqm0-3 added to figure 20-4 ebi connections to memory devices . - table 20-5 , row a15 edited. - section 20.2.7.7 n and flash support edited. - section 20. external memories reorganized. - on figure 6-1 at91sam9g45 memory mapping , ddr2-lpddr-sdram --> ddrsdrc1 and ddr2-lpddr --> ddrsdrc20. - all ddr2sdrc changed into ddrsdrc. 7123 7027 6924 6946 mechanical ch aracteristics - new figure 47-1 324-ball tfbga package drawing and max. weight changed in table 47-2 - all nominal changed into typical. - an empty square after letter v removed from the section 49.1 marking table. 6954 rfo pmc - note added to section 25.3 master clock controller and section 25.11.12 pmc master clock register . 7106
1202 6438fCatarmC21-jun-10 at91sam9g45 6438f usart - lin mode condition now shown in section 33. universal synchronous asynchronous receiver transmitter (usart) . 6944 doc. rev comments change request ref. 6438e introduction: ?two three-channel 32-bit timer/counte rs? peripheral feature changed into two three-channel 16-bit timer/counters . 6828 ecc row added to figure 6-1 at91sam9g45 memory mapping 6842 typos corrected in table 8-1 : ac97 --> ac97c (also in table 23-1 and table 41-1 ), pwmc --> pwm, rng --> trng (also in figure 2-1 and table 46-4 ) rfo bus matrix (matrix): figure 19-1 ?ddr multi-port? , and text above and below added. 1 row and 1 column added to table 19-3 and table 19-4 . 6797 ddr/sdr sdram controller (ddrsdrc): no_opti bit removed. dis_anticip_read description edited. 6871 electrical characteristics: section 46.14 ddrsdrc timings , list of supported speed grade limitations updated. 6776 section 46.11 touch screen adc (tsadc) , tth (ns) formula edited. last sentence in the note added. 6800 rfo spi master mode figure titles reversed between figure 46-5 and figure 46-6 . spi master and slave mode figure titles edited again, from figure 46-5 spi master mode 1 and 2 to figure 46-8 spi slave mode 1 and 2 6847 6872 table 46-2 dc characteristics, i sc values changed. 6903 ethernet mac 10/100 (emac): wake-on-lan feature activated, including section 35.4.12 wake-on-lan support and section 35.6.26 wake-on-lan register . emac interrupt on wake-on-lan event activated. 6836 6838 peripheral dma controller (pdc): typos corrected in table 23-1 : ac97 --> ac97c and tsdac --> tsadcc rfo power management controller (pmc): section 25.11.13 pmc programmable clock register , css and slcmck fields edited. 6844 universal synchronous asynchronous receiver transmitter (usart): section 33. universal synchronous asyn chronous receiver transmitter (usart) , spi feature added. 6837 doc. rev comments change request ref.
1203 6438fCatarmC21-jun-10 at91sam9g45 doc. rev comments change request ref. 6438d introduction: features part was edited. 6715 lfbga replaced by tfbga in features part and section 4.1 rfo section 3. signal description , table 3-1 , touch screen analog-to-digital converter9 part, was edited. 6647 vddcore removed from ground pins gnd are common to... sentence in section 5.1 power supplies rfo section 6.3 i/o drive selection and delay control was added. 6702 figure 6.3 was removed. 0x00500000 changed into 0x00400000 in section 6.2.3 internal rom . fast and slow changed into high and low in section 6.3.1 i/o drive selection 6715 at91sam9g45 debug and test: value 0x819b 05a1 changed into 0x819b 05a1 in section 10.6.4 debug unit 6715 boot strategies: section 11.4.3.1 nand flash boot , and table 11-3 , cs0 changed into cs3. section 11.4.3.4 twi eeprom boot and table 11-3 , twi, twd and twck changed into twi0, twd0 and twck0. 6682 ddr/sdr sdram controller (ddrsdrc): watermarks removed from section 22. ddr/sdr sdram controller (ddrsdrc) . rfo electrical characteristics: a core power supply por characteristics section has been added at the end of section 46. at91sam9g45 electrical characteristics . 6664 section 46.8 pll characteristics , a startup time (t) line was added to table 46-14 and table 46-16 . 2 values were added to clock characteristics table 46-4 and table 46-5 . 6672 the following sections were added: section 46.13 smc timings , section 46.14 ddrsdrc timings , section 46.15 peripheral timings 6637 5 ripple values added to table 46-2 on page 1157 .6689 figure 46-5 and figure 46-6 titles reversed. 6769 maximum operating voltage values edited in table 46-1 on page 1157 . table 46-2 on page 1157 updated: - v t- and v t+ edited; v hys added. - i o ranges edited. - isc max value changed into tbd. table 46-17 on page 1166 , and note below, edited. section 46.10, i/o drive level, removed. rfo external memories: section 20.1.6.1 2x8-bit ddr2 title changed (was 16-bit ddr2) section 20.2.8.2 16-bit lpddr on ebi added 6741
1204 6438fCatarmC21-jun-10 at91sam9g45 6438d lcd controller (lcdc): section 45.12.12 lcd timing configuration register 1 , - replaced by 1 for bit 31, and bit 31 must be written to 1 added to vhdly definition. 6685 parallel input/output controller (pio): - delay registers were addded in a section 30.4.12 programmable i/o delays and associated register description added in a section 30.6.30 pio i/o delay register . - write protected registers description added, together with section 30.6.31 pio write protect mode register and section 30.6.32 pio write protect status register . in section 30.6.11 pio clear output data register , p0-p31: set output data changed into p0-p31: clear output data all slewrate changed into drive. all io changed into i/o. all section 30.6 parallel input/output controller (pio) user interface headers now start with pio only. any extra controller or controller pio removed. 6715 static memory controller (smc): table 21-5 removed from section 21.8.6 reset values of timing parameters . cross-referenced table 21-8 instead. 6742 usb host port: section 37. usb high speed host port (uhphs) , hs (high speed) was added to the title. 6644 doc. rev comments change request ref. 6438c introduction: section 3. signal description , table 3-1 , in reset/test description, nrst pin updated with note concerning nrst configuration. section 4. package and pinout , table 4-1 updated. 6600 6639 boot program: section 11.5.2.1 supp orted external cryst al/external clocks , ...supports 12 mhz... 6598 rstc: section 12.5 reset controller (rstc) user interface table 12-1 mode register backup reset value is 0x0000 0001. 6639 doc. rev comments change request ref. 6438b ddrsdrc: section 22.7.3 ddrsdrc configuration register , bit named enrdm removed from register. section 22.7.9 ddrsdrc dll register bits named, sdcovf, sdcudf, sderf, sdval, sdcval removed from register. 6606 doc. rev comments change request ref.
1205 6438fCatarmC21-jun-10 at91sam9g45 doc. rev comments change request ref. 6438a first issue
1206 6438fCatarmC21-jun-10 at91sam9g45
i 6438fCatarmC21-jun-10 at91sam9g45 table of contents features ................ ................ .............. ............... .............. .............. ............ 1 1 description ............ .............. .............. ............... .............. .............. ............ 2 2 block diagram ............ ................ ................. ................ ................. ............ 3 3 signal description .............. .............. ............... .............. .............. ............ 4 4 package and pinout ................. ................ ................. ................ ............. 11 4.1 mechanical overview of the 324-ball tfbga package ...................................11 4.2 324-ball tfbga package pinout .....................................................................12 5 power considerations ........ .............. ............... .............. .............. .......... 14 5.1 power supplies ................................................................................................14 6 memories ............... .............. .............. ............... .............. .............. .......... 15 6.1 memory mapping .............................................................................................16 6.2 embedded memories ......................................................................................16 6.3 i/o drive selection and delay control .............................................................17 7 system controller ............. ................ ............... .............. .............. .......... 19 7.1 system controller mapping .............................................................................20 7.2 system controller block diagram ....................................................................21 7.3 chip identification ............................................................................................22 7.4 backup section ................................................................................................22 8 peripherals ............ .............. .............. ............... .............. .............. .......... 23 8.1 peripheral mapping .........................................................................................23 8.2 peripheral identifiers ........................................................................................23 8.3 peripheral interrupts and clock control ..........................................................24 8.4 peripheral signals multiplexing on i/o lines ...................................................24 9 arm926ej-s processor overview .............. ................. .............. .......... 31 9.1 description .......................................................................................................31 9.2 embedded characteristics ..............................................................................32 9.3 block diagram .................................................................................................33 9.4 arm9ej-s processor ......................................................................................34 9.5 cp15 coprocessor ..........................................................................................42 9.6 memory management unit (mmu) ..................................................................44 9.7 caches and write buffer .................................................................................46
ii 6438fCatarmC21-jun-10 at91sam9g45 9.8 tightly-coupled memory interface ..................................................................48 9.9 bus interface unit ............................................................................................49 10 at91sam9g45 debug and test .... ................. .............. .............. .......... 51 10.1 description .......................................................................................................51 10.2 embedded characteristics ..............................................................................51 10.3 block diagram .................................................................................................52 10.4 application examples ......................................................................................53 10.5 debug and test pin description ......................................................................54 10.6 functional description .....................................................................................55 11 boot strategies ............... ................ ................. .............. .............. .......... 57 11.1 boot program ..................................................................................................57 11.2 flow diagram ..................................................................................................58 11.3 device initialization ..........................................................................................59 11.4 nvm boot ........................................................................................................60 11.5 sam-ba monitor ..............................................................................................66 12 reset controller (rstc) .... ............... ............... .............. .............. .......... 71 12.1 description .......................................................................................................71 12.2 embedded characteristics ..............................................................................71 12.3 block diagram .................................................................................................71 12.4 functional description .....................................................................................72 12.5 reset controller (rstc) user interface ..........................................................80 13 real-time timer (rtt) ......... .............. ............... .............. .............. .......... 85 13.1 description .......................................................................................................85 13.2 embedded characteristics ..............................................................................85 13.3 block diagram .................................................................................................85 13.4 functional description .....................................................................................85 13.5 real-time timer (rtt) user interface .............................................................88 14 real-time clock (rtc) ........ .............. ............... .............. .............. .......... 93 14.1 description .......................................................................................................93 14.2 embedded characteristics ..............................................................................93 14.3 block diagram .................................................................................................93 14.4 product dependencies ....................................................................................94 14.5 functional description .....................................................................................94 14.6 reset controller (rtc) user interface ............................................................97
iii 6438fCatarmC21-jun-10 at91sam9g45 15 periodic interval time r (pit) ............... .............. .............. ............ ........ 111 15.1 description .....................................................................................................111 15.2 embedded characteristics ............................................................................111 15.3 block diagram ...............................................................................................111 15.4 functional description ...................................................................................111 15.5 periodic interval timer (pit) user interface ..................................................113 16 watchdog timer (wdt) ......... ................ ................. ................ ............. 117 16.1 description .....................................................................................................117 16.2 embedded characteristics ............................................................................117 16.3 block diagram ...............................................................................................117 16.4 functional description ...................................................................................118 16.5 watchdog timer (wdt) user interface .........................................................120 17 shutdown controller (shdwc ) .............. ................. ................ ........... 123 17.1 description .....................................................................................................123 17.2 embedded characteristics ............................................................................123 17.3 block diagram ...............................................................................................123 17.4 i/o lines description .....................................................................................124 17.5 product dependencies ..................................................................................124 17.6 functional description ...................................................................................125 17.7 shutdown controller (shdwc) user interface .............................................126 18 general purpose backup regi sters (gpbr) ............ .............. ........... 129 18.1 description .....................................................................................................129 18.2 embedded characteristics ............................................................................129 18.3 general purpose backup registers (gpbr) user interface ........................129 19 bus matrix (matrix) ........ .............. .............. .............. .............. ........... 131 19.1 description .....................................................................................................131 19.2 embedded characteristics ............................................................................131 19.3 memory mapping ...........................................................................................133 19.4 special bus granting mechanism .................................................................133 19.5 arbitration ......................................................................................................135 19.6 write protect registers ..................................................................................138 19.7 bus matrix (matrix) user interface .............................................................139 20 external memories ............ .............. .............. .............. .............. ........... 155 20.1 programmable i/o lines power supplies and drive levels ..........................155
iv 6438fCatarmC21-jun-10 at91sam9g45 20.2 ddr2 controller ............................................................................................155 20.3 external bus interface (ebi) ..........................................................................160 21 static memory controller (smc) ........... ................. ................ ............. 183 21.1 description .....................................................................................................183 21.2 i/o lines description .....................................................................................183 21.3 multiplexed signals ........................................................................................183 21.4 application example ......................................................................................184 21.5 product dependencies ..................................................................................184 21.6 external memory mapping .............................................................................185 21.7 connection to external devices ....................................................................185 21.8 standard read and write protocols ..............................................................190 21.9 automatic wait states ...................................................................................198 21.10 data float wait states ...................................................................................203 21.11 external wait .................................................................................................207 21.12 slow clock mode ...........................................................................................213 21.13 asynchronous page mode ............................................................................216 21.14 programmable io delays ..............................................................................219 21.15 static memory controller (smc) user interface ............................................220 22 ddr/sdr sdram cont roller (ddrsdrc) ............ ................ ............. 227 22.1 description .....................................................................................................227 22.2 ddrsdrc module diagram .........................................................................228 22.3 product dependencies ..................................................................................229 22.4 functional description ...................................................................................234 22.5 software interface/sdram organization, address mapping ........................253 22.6 programmable io delays ..............................................................................256 22.7 ddr-sdram controller (ddrsdrc) user interface ...................................256 23 error corrected code cont roller (ecc) ...... .............. .............. ........... 275 23.1 description .....................................................................................................275 23.2 block diagram ...............................................................................................275 23.3 functional description ...................................................................................275 23.4 error corrected code controller (ecc) user interface .................................280 23.5 registers for 1 ecc for a page of 512/1024/2048/4096 bytes ......................291 23.6 registers for 1 ecc per 512 bytes for a page of 512/2048/4096 bytes, 8-bit word .......................................................................................................293 23.7 registers for 1 ecc per 256 bytes for a page of 512/2048/4096 bytes, 8-bit word .......................................................................................................301
v 6438fCatarmC21-jun-10 at91sam9g45 24 peripheral dma controller (pdc) ................ .............. .............. ........... 317 24.1 description .....................................................................................................317 24.2 embedded characteristics ............................................................................317 24.3 block diagram ...............................................................................................319 24.4 functional description ...................................................................................319 24.5 peripheral dma controller (pdc) user interface ..........................................322 25 clock generator ................ .............. .............. .............. .............. ........... 333 25.1 description .....................................................................................................333 25.2 embedded characteristics ............................................................................333 25.3 slow clock crystal oscillator .........................................................................333 25.4 slow clock rc oscillator ...............................................................................334 25.5 slow clock selection .....................................................................................334 25.6 main oscillator ...............................................................................................337 25.7 divider and plla block .................................................................................338 25.8 utmi bias and phase lock loop programming ...........................................339 26 power management controller (pmc) .... ................. ................ ........... 340 26.1 description .....................................................................................................340 26.2 embedded characteristics ............................................................................340 26.3 master clock controller .................................................................................342 26.4 processor clock controller ............................................................................342 26.5 usb device and host clocks .........................................................................343 26.6 lp-ddr/ddr2 clock ....................................................................................343 26.7 peripheral clock controller ............................................................................343 26.8 programmable clock output controller .........................................................344 26.9 programming sequence ................................................................................344 26.10 clock switching details .................................................................................348 26.11 power management controllerr (pmc) user interface .................................351 27 advanced interrupt controller (aic) ........... .............. .............. ........... 371 27.1 description .....................................................................................................371 27.2 embedded characteristics ............................................................................371 27.3 block diagram ...............................................................................................372 27.4 application block diagram .............................................................................372 27.5 aic detailed block diagram ..........................................................................372 27.6 i/o line description .......................................................................................373 27.7 product dependencies ..................................................................................373
vi 6438fCatarmC21-jun-10 at91sam9g45 27.8 functional description ...................................................................................374 27.9 advanced interrupt controller (aic) user interface .......................................384 28 debug unit (dbgu) .. ................ ................ ................. ................ ........... 395 28.1 description .....................................................................................................395 28.2 embedded characteristics ............................................................................395 28.3 block diagram ...............................................................................................396 28.4 product dependencies ..................................................................................397 28.5 uart operations ..........................................................................................397 28.6 debug unit (dbgu) user interface ...............................................................404 29 parallel input/output contro ller (pio) ......... .............. .............. ........... 419 29.1 description .....................................................................................................419 29.2 block diagram ...............................................................................................420 29.3 product dependencies ..................................................................................421 29.4 functional description ...................................................................................422 29.5 i/o lines programming example ...................................................................428 29.6 parallel input/output controller (pio) user interface ....................................429 30 serial peripheral interface (spi) ................ ................ .............. ........... 449 30.1 description .....................................................................................................449 30.2 embedded characteristics ............................................................................449 30.3 block diagram ...............................................................................................450 30.4 application block diagram .............................................................................451 30.5 signal description .........................................................................................452 30.6 product dependencies ..................................................................................452 30.7 functional description ...................................................................................453 30.8 serial peripheral interface (spi) user interface ............................................467 31 two-wire interface (twi) .... .............. ............... .............. .............. ........ 481 31.1 description .....................................................................................................481 31.2 embedded characteristics ............................................................................481 31.3 list of abbreviations ......................................................................................482 31.4 block diagram ...............................................................................................482 31.5 application block diagram .............................................................................483 31.6 product dependencies ..................................................................................483 31.7 functional description ...................................................................................484 31.8 master mode ..................................................................................................486 31.9 multi-master mode .........................................................................................498
vii 6438fCatarmC21-jun-10 at91sam9g45 31.10 slave mode ....................................................................................................501 31.11 two-wire interface (twi) user interface .......................................................509 32 universal synchronous asynchr onous receiver transmitter (usart) ................. ................. ................ ................. ................ ............. 523 32.1 description .....................................................................................................523 32.2 embedded characteristics ............................................................................523 32.3 block diagram ...............................................................................................524 32.4 application block diagram .............................................................................525 32.5 i/o lines description ....................................................................................526 32.6 product dependencies ..................................................................................527 32.7 functional description ...................................................................................528 32.8 universal synchronous asynchro nous receiver transmitter (usart) user interface ...............................................................................................558 33 timer counter (tc) ........... .............. .............. .............. .............. ........... 579 33.1 description .....................................................................................................579 33.2 embedded characteristics ............................................................................579 33.3 block diagram ...............................................................................................580 33.4 pin name list ................................................................................................581 33.5 product dependencies ..................................................................................581 33.6 functional description ...................................................................................582 33.7 timer counter (tc) user interface ................................................................595 34 synchronous serial controller (ssc) .... ................. ................ ........... 613 34.1 description .....................................................................................................613 34.2 embedded characteristics ............................................................................613 34.3 block diagram ...............................................................................................614 34.4 application block diagram .............................................................................615 34.5 pin name list ................................................................................................616 34.6 product dependencies ..................................................................................616 34.7 functional description ...................................................................................618 34.8 ssc application examples ............................................................................630 34.9 synchronous serial controller (ssc) user interface ....................................632 35 high speed multimedia card interface (hsmci) ....... .............. ........... 655 35.1 description .....................................................................................................655 35.2 embedded characteristics ............................................................................655 35.3 block diagram ...............................................................................................656
viii 6438fCatarmC21-jun-10 at91sam9g45 35.4 application block diagram .............................................................................657 35.5 pin name list ...............................................................................................657 35.6 product dependencies ..................................................................................658 35.7 bus topology .................................................................................................659 35.8 high speed multimedia card operations ......................................................661 35.9 sd/sdio card operation ..............................................................................680 35.10 ce-ata operation .........................................................................................681 35.11 hsmci boot operation mode ........................................................................682 35.12 hsmci transfer done timings .....................................................................684 35.13 multimedia card interface (mci) user interface ............................................686 36 ethernet mac 10/100 (emac) .. ............... ................. ................ ........... 715 36.1 description .....................................................................................................715 36.2 embedded characteristics ............................................................................715 36.3 block diagram ...............................................................................................716 36.4 functional description ...................................................................................717 36.5 programming interface ..................................................................................728 36.6 ethernet mac 10/100 (emac) user interface ...............................................731 37 usb high speed host port (uhphs) .......... .............. .............. ........... 765 37.1 description .....................................................................................................765 37.2 embedded characteristics ............................................................................765 37.3 block diagram ...............................................................................................766 37.4 product dependencies ..................................................................................767 37.5 i/o lines ........................................................................................................767 37.6 typical connection ........................................................................................770 38 usb high speed device port (udphs) .......... .............. .............. ........ 771 38.1 description .....................................................................................................771 38.2 embedded characteristics ............................................................................771 38.3 block diagram ...............................................................................................773 38.4 typical connection ........................................................................................774 38.5 functional description ...................................................................................775 38.6 usb high speed device port (udphs) user interface ................................799 39 image sensor interface (isi) ............. ............... .............. .............. ........ 841 39.1 description .....................................................................................................841 39.2 embedded characteristics ............................................................................841 39.3 block diagram ...............................................................................................842
ix 6438fCatarmC21-jun-10 at91sam9g45 39.4 functional description ...................................................................................843 39.5 image sensor interface (isi) user interface ..................................................851 40 touch screen adc controller (tsadcc) .. ............... .............. ........... 881 40.1 description .....................................................................................................881 40.2 embedded characteristics ............................................................................881 40.3 block diagram ...............................................................................................882 40.4 signal description ..........................................................................................883 40.5 product dependencies ..................................................................................883 40.6 analog-to-digital converter functional description .......................................884 40.7 touch screen ................................................................................................885 40.8 conversion results .......................................................................................890 40.9 conversion triggers ......................................................................................892 40.10 operating modes ...........................................................................................892 40.11 touch screen adc controller (tsadcc) user interface .............................900 41 dma controller (dmac) ................. .............. .............. .............. ........... 919 41.1 description .....................................................................................................919 41.2 embedded characteristics ............................................................................919 41.3 block diagram ...............................................................................................921 41.4 functional description ...................................................................................922 41.5 dmac software requirements .....................................................................948 41.6 dma controller (dmac) user interface ........................................................950 42 pulse width modulation c ontroller (pwm) . .............. .............. ........... 973 42.1 description .....................................................................................................973 42.2 embedded characteristics ............................................................................973 42.3 block diagram ...............................................................................................974 42.4 i/o lines description .....................................................................................974 42.5 product dependencies ..................................................................................974 42.6 functional description ...................................................................................975 42.7 pulse width modulation controller (pwm) user interface ............................984 43 ac97 controller (ac97c) .......... ................. ................ .............. ........... 997 43.1 description .....................................................................................................997 43.2 embedded characteristics ............................................................................997 43.3 block diagram ...............................................................................................998 43.4 pin name list ................................................................................................999 43.5 application block diagram .............................................................................999
x 6438fCatarmC21-jun-10 at91sam9g45 43.6 product dependencies ................................................................................1000 43.7 functional description .................................................................................1001 43.8 ac97 controller (ac97c) user interface ....................................................1012 44 true random number generator (trng) ............... .............. ........... 1033 44.1 description ...................................................................................................1033 44.2 true random number generator (trng) user interface ..........................1034 45 lcd controller (lcdc) ....... ................. ................ ................. ............. 1041 45.1 description ...................................................................................................1041 45.2 embedded characteristics ..........................................................................1041 45.3 block diagram .............................................................................................1042 45.4 i/o lines description ...................................................................................1043 45.5 product dependencies ................................................................................1043 45.6 functional description .................................................................................1045 45.7 interrupts .....................................................................................................1066 45.8 configuration sequence ..............................................................................1066 45.9 double-buffer technique .............................................................................1067 45.10 2d memory addressing ...............................................................................1068 45.11 register configuration guide ......................................................................1070 45.12 lcd controller (lcdc) user interface ........................................................1071 46 at91sam9g45 electrical ch aracteristics ..... .............. ........... ......... 1101 46.1 absolute maximum ratings .........................................................................1101 46.2 dc characteristics .......................................................................................1101 46.3 power consumption ....................................................................................1103 46.4 clock characteristics ...................................................................................1105 46.5 main oscillator characteristics ....................................................................1105 46.6 32 khz oscillator characteristics .................................................................1107 46.7 32 khz rc oscillator characteristics ..........................................................1108 46.8 pll characteristics .....................................................................................1109 46.9 i/os ..............................................................................................................1110 46.10 usb hs characteristics ..............................................................................1110 46.11 touch screen adc (tsadc) ......................................................................1112 46.12 core power supply por characteristics ....................................................1113 46.13 smc timings ...............................................................................................1114 46.14 ddrsdrc timings .....................................................................................1117 46.15 peripheral timings .......................................................................................1118
xi 6438fCatarmC21-jun-10 at91sam9g45 47 at91sam9g45 mechanical c haracteristics ............. .............. ......... 1134 47.1 package drawings .......................................................................................1134 47.2 soldering profile ..........................................................................................1135 48 at91sam9g45 ordering information ....... .............. .............. ........... 1136 49 at91sam9g45 errata ......... ................. ................ ................. ............. 1137 49.1 marking ........................................................................................................1137 49.2 errata ...........................................................................................................1138 revision history........ ................ ................ ................. .............. ........... 1139 table of contents.......... ................. ................ ................. ................ ........... i
6438fCatarmC21-jun-10 headquarters international atmel corporation 2325 orchard parkway san jose, ca 95131 usa tel: 1(408) 441-0311 fax: 1(408) 487-2600 atmel asia unit 1-5 & 16, 19/f bea tower, millennium city 5 418 kwun tong road kwun tong, kowloon hong kong tel: (852) 2245-6100 fax: (852) 2722-1369 atmel europe le krebs 8, rue jean-pierre timbaud bp 309 78054 saint-quentin-en- yvelines cedex france tel: (33) 1-30-60-70-00 fax: (33) 1-30-60-71-11 atmel japan 9f, tonetsu shinkawa bldg. 1-24-8 shinkawa chuo-ku, tokyo 104-0033 japan tel: (81) 3-3523-3551 fax: (81) 3-3523-7581 product contact web site www.atmel.com www.atmel.com/at91sam technical support at91sam support atmel technical support sales contacts www.atmel.com/contacts/ literature requests www.atmel.com/literature disclaimer: the information in this document is provided in connection with atmel products. no license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of atmel products. except as set forth in atmel?s terms and condi- tions of sale located on atmel?s web site, atmel assumes no li ability whatsoever and disclaims any express, implied or statutor y warranty relating to its products including, but not limited to, the implied warranty of merchantability, fitness for a particu lar purpose, or non-infringement. in no event shall atmel be liable for any direct, indirect, consequential, punitive, special or i nciden- tal damages (including, without limitation, damages for loss of profits, business interruption, or loss of information) arising out of the use or inability to use this document, even if atme l has been advised of the possibility of such damages. atmel makes no representations or warranties with respect to the accuracy or comp leteness of the contents of this document and reserves the rig ht to make changes to specifications and product descriptions at any time without notice. atmel does not make any commitment to update the information contained her ein. unless specifically provided otherwise, atmel products are not suitable for, and shall not be used in, automotive applications. atmels products are not int ended, authorized, or warranted for use as components in applications in tended to support or sustain life. ? 2010 atmel corporation . all rights reserved. atmel ? , atmel logo and combinations thereof, dataflash ? , sam-ba ? and others, are regis- tered trademarks or trademarks of atmel corporation or its subsidiaries. arm ? , thumb ? and the armpowered logo ? and others, are registered trademarks or trademarks of arm ltd. windows ? and others, are registered trademarks or trademar ks of microsoft corporation in the us and/or other countries. other terms and product names may be trademarks of others.


▲Up To Search▲   

 
Price & Availability of AT91SAM9G45PRE

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X